How to make this a module (1 Viewer)

ALAN

Registered User.
Local time
Today, 10:36
Joined
Jul 12, 2000
Messages
23
I want to make this statement as a module to be used by severals txtbox..Can sombody please help me , do I have to change certain words in this statement..to make it work..

If IsNull (Me.FieldName) Then
Me.FieldName.visible = False
Else
Me.FieldName.visible = True
End If
 

GaryC

Registered User.
Local time
Today, 10:36
Joined
Apr 25, 2001
Messages
31
Try this !

Function field_visible(myfield As Control)
If IsNull(myfield) Then
myfield.Visible = False
Else
myfield.Visible = True
End If
End Function

Example call to this function
dim x as byte
x = field_visible(me!myfield)
'x stores return value of function - sucess or fail

Good luck



[This message has been edited by GaryC (edited 05-24-2001).]
 

ALAN

Registered User.
Local time
Today, 10:36
Joined
Jul 12, 2000
Messages
23
What about if I have 3 fields (eg: Myfield2, myfield3 and myfield4)...and I want to use this module for all these 3 fields....Where to put the name of these fields?
 

AlanS

Registered User.
Local time
Today, 05:36
Joined
Mar 23, 2001
Messages
292
Two more possible approaches:

1. Set up the following Sub, either in the form's module, or in a standard module if you want to use it with multiple forms:

Sub SetVisible(Ctrl as Control)
Ctrl.Visible = Not IsNull(Ctrl)
End Sub

Then, simply put a call to this Sub wherever you need it. E.g., if you want to set the Visible property of text box Text1 when its form is activated, put the following call in the form's OnActivate event procedure:

SetVisible(Text1)

And/or, you could put the call into the text box's AfterUpdate event procedure, so that visibility would be reset each time the text box was updated.

2. Rather than setting up a separate Sub (or Function), simply use this code:

[ControlName].Visible = Not IsNull([ControlName]
 

Users who are viewing this thread

Top Bottom