Visible Fields

kermit

Registered User.
Local time
Today, 02:35
Joined
Dec 20, 2002
Messages
12
Is there a way to validate all visible fields on a form?
For instance...
Lets say i have a form with a heap load of fields, and based on what the user selects in a drop down box I make certain fields visible and invisible. But what ever fields are made visible i want to make sure that they entered something (the fields are required).
Is there any way to say "All that are visible" cannot be Null?

Hopefully my gibberish has made some sense to what im asking...
thanks for the help!

-frog
 
If you want to loop through the controls - here's some code you can try:
Dim MyForm As Form, C As Control
Set MyForm = Screen.ActiveForm


On Err GoTo TryNextC


' Check each data entry for visible status

For Each C In MyForm.Controls

' Only check data entry type controls.
Select Case C.ControlType

Case acTextBox, acComboBox, acCheckBox, acListBox

If C.Visible = True Then
If IsNull(C) Then
MsgBox "All Fields must be filled in.", vbOKOnly
Cancel = True
Exit Sub
Else
'do nothing, continue
End If
Else
'do nothing
End If

Case Else
'do nothing
End Select


TryNextC:
Next C

HTH
E
 

Users who are viewing this thread

Back
Top Bottom