Why I get Error 2105

C

Chipcom

Hi

I am getting error 2105 and I don't know why, Can you please help me
with that?


The user needs to enter the user name and the password so it inserts
into the database. After that a reference number is created.
Here is the code:


Private Sub Form_BeforeUpdate(Cancel As Integer)


On Error GoTo Error_Handler
Dim db As DAO.Database
Dim rst As DAO.Recordset


Set db = CurrentDb
Set rst = db.OpenRecordset("tblWhatever", dbOpenDynaset)


With rst
.AddNew
!WhateverID = Me.txtWhateverID
!FirstName = Me.txtFName
!LastName = Me.txtLName
.Update
.Bookmark = .LastModified
End With


Exit_Here:
rst.Close
Set rst = Nothing
Set db = Nothing
Exit Sub


Error_Handler:
MsgBox Err.Number
Resume Exit_Here


Cancel = True
Exit Sub


Error_Handler:
MsgBox Err.Number
Resume Exit_Here


End Sub


Public Sub Form_KeyPress(KeyAscii As Integer)


Dim Erro As Integer
'13=Carriage Return
If KeyAscii = 13 Then
On Error GoTo Err_Form_KeyPress


DoCmd.GoToRecord acDataForm, "tblWhatever", acNewRec
Exit_Form_KeyPress:
Exit Sub


Err_Form_KeyPress:
MsgBox Err.Description
MsgBox Err.Number
Resume Exit_Form_KeyPress


End If
End Sub

**Note I am getting the error on MsgBox Err.Number keypress sub and I
don't see the error in the Immediate window.


Thanks
 
B

Baz

If the form "tblWhatever" (why do you have a form named as if it were a
table?) is already open when you insert a record into tblWhatever, then the
form doesn't "know" that you inserted a record. Presumably it's already
sitting there on a new record for what it "believes" is an empty record
source, so you can't go to a new record.
 
C

Chipcom

If the form "tblWhatever" (why do you have a form named as if it were a
table?) is already open when you insert a record into tblWhatever, then the
form doesn't "know" that you inserted a record. Presumably it's already
sitting there on a new record for what it "believes" is an empty record
source, so you can't go to a new record.
























- Show quoted text -



So what to do now?

How to be sure that the table is close?
 
B

Baz

Chipcom said:
So what to do now?

How to be sure that the table is close?

You've lost me. What has closing a table got to do with it?

If my initial guess is correct, then doing the following after adding the
new record might fix it:

Forms!tblWhatever.Requery
 
C

Chipcom

You've lost me. What has closing a table got to do with it?

If my initial guess is correct, then doing the following after adding the
new record might fix it:

Forms!tblWhatever.Requery- Hide quoted text -

- Show quoted text -

Hi

It didn't help me I still got 2105
So I tried to change the line:

DoCmd.GoToRecord acDataForm, "tblWhatever", acNewRec

To:

Me.Requery

And I got Error 2169

Run-time error '2169':
You can't save this record at this time.



So what I need to do now?
 
B

Baz

Chipcom said:
Hi

It didn't help me I still got 2105
So I tried to change the line:

DoCmd.GoToRecord acDataForm, "tblWhatever", acNewRec

To:

Me.Requery

And I got Error 2169

Run-time error '2169':
You can't save this record at this time.



So what I need to do now?

I've no idea, because I don't really understand what it is you are trying to
achieve. Please explain it in functional terms.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top