Is there a "Global Symbol" for all a form's controls? (1 Viewer)

AlexanderX

New member
Local time
Today, 09:10
Joined
Mar 20, 2001
Messages
6
Hello - I'm creating an entry form where the first field that needs to be entered is an ID number.

In the interest of ensuring that this number gets entered before any other information, I'd like to set all the other form controls to Visible=False if the value of the ID field is null. Of course, if there is a value in the ID field, I'd like all the controls to be set to Visible=True.

My question - is there any kind of a global symbol (ala the "*" wildcard) that I can use in my VB code to tell the form to set all controls to Visible=True once there is a value in the ID field?

There are about 30 other controls on the form, and in the interest of saving bytage, I'd like to get around having to specify Visible=True for each and every one of them.

Thanks in advance for any assistance you can give with this!
 

Jack Cowley

Registered User.
Local time
Today, 09:10
Joined
Aug 7, 2000
Messages
2,639
Set the controls you want hidden by setting their visible property to No. This code should make them Visible when you call it.

Function ShowControls()

Dim MyForm As Form, C As Control
Set MyForm = Screen.ActiveForm

For Each C In MyForm.Controls

Select Case C.ControlType
Case acTextBox, acComboBox, acListBox, acOptionGroup
C.Visible = True
End Select
Next C

End Function
 

AlexanderX

New member
Local time
Today, 09:10
Joined
Mar 20, 2001
Messages
6
Thanks mucho Jack - I've tried it and it works pretty well.

The one form control type that doesn't respond to this code, unfortunately, are stand-alone labels. I've tried added "acLabel" to the Case definition statement, and I also tried defining "L as Label" in the dim statement; neither of these worked. Is there any other type of code I need to insert to get labels to become visible? Thanks.
 

AlexanderX

New member
Local time
Today, 09:10
Joined
Mar 20, 2001
Messages
6
OK - I've got it working now. I'd had my form pointing to an old module containing similar code. Mea culpa!
 

Users who are viewing this thread

Top Bottom