Compile Error (1 Viewer)

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
 

Minty

AWF VIP
Local time
Today, 21:52
Joined
Jul 26, 2013
Messages
10,371
The correct syntax is
If Not IsNull(ExceptionID) Then
 

ByteMyzer

AWF VIP
Local time
Today, 13:52
Joined
May 3, 2004
Messages
1,409
Try changing:
Code:
[COLOR="Navy"]If[/COLOR] (NotIsNull(ExceptionID)) [COLOR="navy"]Then[/COLOR]
...to:
Code:
[COLOR="navy"]If[/COLOR] IsNull(ExceptionID) = [COLOR="navy"]False Then[/COLOR]
 

Users who are viewing this thread

Top Bottom