"Clear" Button

B

Bill Case

How can I code a button to clear (erase) the selections
made in multiple combo boxes on the form?

Thank you very much.
 
R

Ragnar Midtskogen

If the combos are bound, that is, based on fields in the form's
recordssource, you can just put the following in the button proc:
Me.Undo
Me.Undo

If they are unbound you have to set each control to Null or a zero length
string ("").

Ragnar
 
G

Gary Miller

Bill,

I assume this is for your search form and they are all
unbound. Try...

Dim ctl as Control

On Error Resume Next
' You will throw errors on labels and such, just ignore.

For Each ctl In Me.Controls
ctl.Value = Null
Next ctl

--

Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
 
B

Bill Case

Hi Ragnar . . .

Thanks for your advice. The boxes are unbound. Can you
kindly provide me with the code to set the fields to
null? I'm quite new to VB (as in, I know what I know
based on people giving me code!).
 

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