Validation Query

nick941741

Registered User.
Local time
Today, 12:55
Joined
Mar 17, 2009
Messages
21
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)
Code:
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
 
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.
 
Good point, well made.

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

Thanks for your help

Nick
 

Users who are viewing this thread

Back
Top Bottom