View Full Version : Validation Query


nick941741
03-20-2009, 06:53 AM
Hi, I have the following bit of very messy code that I have created to check fields for null values when a user click on a certain button. It it shows an X image next to the fields that are null, but I need it to
1, not show the image if the field is not null and
2, Move to the first empty field to promt the user to complete it...

Any help as always apprectiated.

Hidden_missing is the image (X)

Private Sub cmdOpenFormAndAddNewRecord_Click()

If IsNull(Address1) Then
Me!address1_missing.Visible = True
Me!hidden_missing.Visible = True
'DoCmd.GoToControl "Address1"
Else
Me!address1_missing.Visible = False
Me!hidden_missing.Visible = False
End If
If IsNull(PostCode) Then
Me!postcode_missing.Visible = True
Me!hidden_missing.Visible = True
Else
Me!postcode_missing.Visible = False
Me!hidden_missing.Visible = False
'DoCmd.GoToControl "PostCode"
End If

If IsNull(ClientType) Then
Me!clienttype_missing.Visible = True
Me!hidden_missing.Visible = True
Else
Me!clienttype_missing.Visible = False
Me!hidden_missing.Visible = False
End If

FoFa
03-20-2009, 11:15 AM
Well you could do away with all the else's by just setting all the visible properties to false right up front.
No reason to indent the second and third if as they are not part of the first if.
But other than that I would go with it.

nick941741
03-21-2009, 04:59 AM
Good point, well made.

Always nice to have a fresh pair of eyes look at something.

Thanks for your help

Nick