Johnny Drama
In need of beer...
- Local time
- Today, 13:52
- Joined
- Dec 12, 2008
- Messages
- 211
Hi All,
I'm having a problem with some VBA code. This was converted from a Macro using the Covert to VBA tool in Access 2016. When I run the code it fails at the line in bold below. The error message is Compile error: Sub or Function not defined.
Any help would be appreciated.
Private Sub ExceptionID_Click()
On Error GoTo ExceptionID_Click_Err
On Error Resume Next
If (Form.Dirty) Then
DoCmd.RunCommand acCmdSaveRecord
End If
If (MacroError.Number <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
Exit Sub
End If
On Error GoTo 0
DoCmd.OpenForm "Exception Details", acNormal, "", "[ExceptionID]=" & Nz(ExceptionID, 0), , acDialog
If (NotIsNull(ExceptionID)) Then
TempVars.Add "CurrentID", ExceptionID
End If
If (IsNull(ExceptionID)) Then
TempVars.Add "CurrentID", Nz(DMax("[ExceptionID]", Form.RecordSource), 0)
End If
DoCmd.Requery ""
DoCmd.SearchForRecord , "", acFirst, "[ExceptionID]=" & TempVars!CurrentID
TempVars.Remove "CurrentID"
ExceptionID_Click_Exit:
Exit Sub
ExceptionID_Click_Err:
MsgBox Error$
Resume ExceptionID_Click_Exit
End Sub
I'm having a problem with some VBA code. This was converted from a Macro using the Covert to VBA tool in Access 2016. When I run the code it fails at the line in bold below. The error message is Compile error: Sub or Function not defined.
Any help would be appreciated.
Private Sub ExceptionID_Click()
On Error GoTo ExceptionID_Click_Err
On Error Resume Next
If (Form.Dirty) Then
DoCmd.RunCommand acCmdSaveRecord
End If
If (MacroError.Number <> 0) Then
Beep
MsgBox MacroError.Description, vbOKOnly, ""
Exit Sub
End If
On Error GoTo 0
DoCmd.OpenForm "Exception Details", acNormal, "", "[ExceptionID]=" & Nz(ExceptionID, 0), , acDialog
If (NotIsNull(ExceptionID)) Then
TempVars.Add "CurrentID", ExceptionID
End If
If (IsNull(ExceptionID)) Then
TempVars.Add "CurrentID", Nz(DMax("[ExceptionID]", Form.RecordSource), 0)
End If
DoCmd.Requery ""
DoCmd.SearchForRecord , "", acFirst, "[ExceptionID]=" & TempVars!CurrentID
TempVars.Remove "CurrentID"
ExceptionID_Click_Exit:
Exit Sub
ExceptionID_Click_Err:
MsgBox Error$
Resume ExceptionID_Click_Exit
End Sub