If.. Endif statement not working

cath_hopes

Registered User.
Local time
Today, 14:41
Joined
Oct 17, 2007
Messages
52
Hi there - I seem to have a data type mismatch or something - the following simple If...End If statement is not working:

...
'Check House Name/ Number and Postcode are populated:
If Me.House_Name__Number.Value = Null Or Me.Postcode.Value = Null Then
MsgBox "Both House Name/ Number and Postcode must be correctly populated."
Else
DoCmd.Close acForm, "PropertyForm", acSavePrompt
End If
...

I have blanked both the Postcode and the House Name/ Number yet the Msgbox does not get invoked in my form. I've tried changing Null to " " but that doesn't work either.
Both Postcode and House Name/ Number are text fields from a table and editable fields on my form.

Hopefully this is a quick one to fix!
Thanks!
 
Code should be

If IsNull(Me.House_Name__Number)l Or IsNull(Me.Postcode) Then


Brian
 
Something else too...

NULL definition = "No Value"

Thus, .Value = NULL is not possible.

At least with "IsNull(Me.Control), you are telling Access to check for a NULL instead of telling it that NULL IS a value. I'm sure the program doesn't like that. :)
 
Thanks Brian - it now works fine.
Thanks ajetrumpet - I've noted your comments in my VBA useful tips file!
 
Last edited:

Users who are viewing this thread

Back
Top Bottom