Why I am getting Error 2105

  • Thread starter Thread starter Chipcom
  • Start date Start date
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


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


Thanks
 
At the very least, you are missing an End If:

If KeyAscii = 13 Then
On Error GoTo Err_Form_KeyPress
DoCmd.GoToRecord acDataForm, "tblWhatever", acNewRec
End If

Also, your Form_BeforeUpdate has 2 identically named Error_Handler: labels.
The first one is the only one that will ever be executed, so you can delete
the 2nd. (This is not causing a problem).


HTH,
 
Back
Top