Clearing form control values

M

ME

I have a form with several combo boxes and checkboxes that
feed an uderlying query. I know I can clear the controls
with ME!Control = NUll but I would like to add a CLEAR
SELECTION button that will reset ALL controls to NULL
without having to list out each control. Is this possible
and how. I appreciate any pointers.
 
G

Gerald Stanley

The required code would be something along the lines of
Dim ctl As Control

For Each ctl In Me.Controls
Select Case Me.ControlType
Case acComboBox, acTextBox, etc
ctl.Value = Null
End Select
Next

The case is important as you are unlikely to want to clear
all controls. Also, not every control type has a Value
property. You will need to check against the Access Help
file as to which values you need to include in the Case clause

Hoe This Helps
Gerald Stanley MCSD
 

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