Refresh a form

G

Guus

Hello,
I am building a routine (module) to refresh the content of an Accessform.

The fields (textboxes, combo-boxes, and their lables, and the commandbuttons
as well, I will define in certain situation to make them visible or to enable
them.

But....first of all, I want to 'clear' my form or make all my information
invisible.

My question is: do you have for me a simple routine (module), that makes all
my information, mentioned above, invisible...and disabled.

Some extra information: on my form there are textboxes, labels, combo-boxes
and commandbuttons (sorry....I do not know: are all these called 'controls'?)

I appreciate to receive a piece of VBA-code to clear, disable and to make
invisible all the 'controls' (?) on my Accessform.

Thank you very much in advance,
Guus
 
M

Marshall Barton

Guus said:
I am building a routine (module) to refresh the content of an Accessform.

The fields (textboxes, combo-boxes, and their lables, and the commandbuttons
as well, I will define in certain situation to make them visible or to enable
them.

But....first of all, I want to 'clear' my form or make all my information
invisible.

My question is: do you have for me a simple routine (module), that makes all
my information, mentioned above, invisible...and disabled.

Some extra information: on my form there are textboxes, labels, combo-boxes
and commandbuttons (sorry....I do not know: are all these called 'controls'?)

I appreciate to receive a piece of VBA-code to clear, disable and to make
invisible all the 'controls' (?) on my Accessform.


Yes, everything on a form/report is a control.

If you make every control invisible (or disabled) you will
not be able to interact with the form, including whatever
will make them visible again.

If you make a data control (text box, combo box, etc)
invisible, its attached label (if there is one) will also
become invisible so ther is no benefit from hiding an
attached label when you make a control invisible..

With all that in mind, I suggest that you use the control's
Tag property to specify what you want done to the controls.
Let's say you put the letter V in the Tag property to
indicate that you want to make the control visible or
invisible, the letter E for Enabled/Disabled and C for set
the control's value to Null.

Then, you can use a procedure to loop through all the
controls, do the things specified in the Tag property
according to procedure arguments. The procedure could look
something like this air code:

Sub SetControls(varClear, varVisible, varEnable)
'varClear True to set value to Null, False or Null to leave
it alone
'varVisible True to make Visible, False to hide, Null to
leave it alone
'varEnable True to enable, False to disable, Null to leave
it alone

Dim ctl As Control

For Each ctl In Me.Controls
If ctl.Tag Like "*C*" And varClear = TrueThen
ctl = Null
End If
If ctl.Tag Like "*V*" And Not IsNull(varVisible)Then
ctl.Visible = varVisible
End If
If ctl.Tag Like "*E*" And Not IsNull(varEnable)Then
ctl.Enable= varEnable
End If
Next ctl
End Sub

Then, whenever you want to do one of these "group" type of
operations, you can just call the procedure.
 
G

Guus

Hello Marsh,
Thank you very much for your explanation, now I have to still a quite job,
but it's clear what you have tried to explain.

Thank you very much,
Guus
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top