Invalid message

superrob5

Registered User.
Local time
Today, 23:57
Joined
May 8, 2003
Messages
99
anyone know what this means

Invalid reference to field 'form_beforeupdate'

this is the code
Sub Form_BeforeUpdate (Cancel As Integer)
If Not ((Not IsNull(Me!HIVPOTC)) And (Not IsNull(Me!Result)) Or (IsNull(Me!HIVPOTC)) And (IsNull(Me!Result))) Then
If (IsNull(Me!Result)) Then
Cancel = True
MsgBox "Result is empty"
Result.SetFocus
Else
Cancel = True
MsgBox "HIVPOTC is empty"
HIVPOTC.SetFocus
End If
Else
'doing nothing becasue its both filled
'or both not filled
End If
End Sub
 
I just found the answer but is there away to automatically hit the ok button on this error so the user doesnt see it
 
add an error handler to the code
 
How about...
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo Err_Form_BeforeUpdate
    
    If IsNull(Result) Then
        Cancel = True
        Me.Result.SetFocus
        MsgBox "Result is empty"
    ElseIf IsNull(HIVPOTC) Then
        Cancel = True
        Me.HIVPOTC.SetFocus
        MsgBox "HIVPOTC is empty"
    Else
        'do nothing
    End If
    
Exit_Form_BeforeUpdate:
    Exit Sub
    
Err_Form_BeforeUpdate:
    MsgBox Err.Number & " - " & Err.Description, "Form_BeforeUpdate"
    Resume Exit_Form_BeforeUpdate
    
End Sub
HTH
 
the reason why I have that big if statement is becasue I am checking the 2 fields. If they have both have info or both dont have info then put a not infront that means that one of them might have a null. Which then I will test for which one. Thats why I can leave that statements out.

ROb
 

Users who are viewing this thread

Back
Top Bottom