When the X is clicked to close the form, I get the following error:
The Jet database engine cannot find a record in the table "Firm" with the key matching field FIRM#
This error occurs in the "Before Update" section of code as the "End Sub" is executed.
I am lost as to why I get this. I look in the table "Firm" and there is an appropriate record with the right FIRM#.
Thank You (code below)
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strmsg As String
Dim strMsg1 As String
Dim Result As Integer
Me.Firm_.Requery
strmsg = "Do you wish to save your changes?"
If MsgBox(strmsg, vbQuestion + vbYesNo, "Save Record?"
= vbYes Then
If Me.[Firm#] = 0 Then
strMsg1 = "Must select a firm"
Result = MsgBox(strMsg1, vbOKOnly, "Warning"
DoCmd.RunCommand acCmdUndo
DoCmd.CancelEvent
Else
Me.Text56 = Me.ID
[Date Updated] = Date
[Time Updated] = Time()
[Updator] = GetTheCurrentUser()
End If
Else
DoCmd.RunCommand acCmdUndo
DoCmd.CancelEvent
End If
Me.Firm_.Requery
End Sub
The Jet database engine cannot find a record in the table "Firm" with the key matching field FIRM#
This error occurs in the "Before Update" section of code as the "End Sub" is executed.
I am lost as to why I get this. I look in the table "Firm" and there is an appropriate record with the right FIRM#.
Thank You (code below)
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim strmsg As String
Dim strMsg1 As String
Dim Result As Integer
Me.Firm_.Requery
strmsg = "Do you wish to save your changes?"
If MsgBox(strmsg, vbQuestion + vbYesNo, "Save Record?"
If Me.[Firm#] = 0 Then
strMsg1 = "Must select a firm"
Result = MsgBox(strMsg1, vbOKOnly, "Warning"
DoCmd.RunCommand acCmdUndo
DoCmd.CancelEvent
Else
Me.Text56 = Me.ID
[Date Updated] = Date
[Time Updated] = Time()
[Updator] = GetTheCurrentUser()
End If
Else
DoCmd.RunCommand acCmdUndo
DoCmd.CancelEvent
End If
Me.Firm_.Requery
End Sub