Hi,
I am not sure this will help. But if you have time take a look on it. I have copy some where on the net but I can find the hyperlink. I didn't try it.
'
Adding Simple Validation...
Making Sure the User Fills In All the Fields
A Function to Pinpoint Missing Data
Here is an example of how you can write a piece of "generic" code to check that the form has been filled in. You could, of course, set the Required property of each field to Yes but this method involves less work and gives you the opportunity to display a friendly message and take the user straight to the appropriate field.
In the same code module as the form's event procedures, create the following custom function. You can enter it after the last of the event procedures:
Private Function CheckData() As Boolean
CheckData = True
Dim ctl As Control
Dim strName As String
For Each ctl In Me.Controls
If IsNull(ctl) Then
strName = ctl.Controls(0).Caption
CheckData = False
MsgBox "Please fill in the " & Chr(34) & strName & Chr(34) & " field."
ctl.SetFocus
Exit Function
End If
Next ctl
End Function
How the Function Works
The CheckData function returns False if it finds an empty text box or True if it does not (hence its declaration as Boolean). The first line sets the value of the function to True. It uses a For... Next loop to look in turn at each control on the form. If no empty controls are found the function returns the value True.
If it comes across an empty control an If Statement is invoked in which it notes the control's Caption (i.e. the Caption property of the label of a text box) and sets the value of the function to false. It then displays a message box incorporating the control's caption telling the user which control is missing data. Finally it sets the focus of the form to that control by placing the user's cursor into the control. At this point the function exits so that the user can correct their input.
Applying the Function
To make use of the function, add the line:
If CheckData = False Then Exit Sub
as the first line of each of the Click event procedures for the three tabs. When the user clicks one of the tabs, before anything else happens, the function is evaluated. If it returns True (meaning that there are no empty fields) the rest of the Click event procedure runs. If it returns False the Click event procedure exits (i.e. is cancelled) and the user is shown a message and taken to the appropriate field.
Hope this will help.
Le