Query by Form--Clear Selection Criteria

  • Thread starter Thread starter Ramona Goutiere
  • Start date Start date
R

Ramona Goutiere

I have developed a form that queries for information across one or more
fields, depending on what information the user enters into the fields.

I want users to be able to clear ALL the old selection criteria on the form
before they begin a new search (instead of deleting the information out of
each form field individually). My preference would be to use a "Clear"
command button, but I don't know how to define the macro or VBA code needed.

Would anyone have any ideas on how to accomplish this? I'm new to macros
and eager to learn more about how they work. Any assistance will be
sincerely appreciated.

Thanks much!

Ramona
 
Ramona said:
I have developed a form that queries for information across one or more
fields, depending on what information the user enters into the fields.

I want users to be able to clear ALL the old selection criteria on the form
before they begin a new search (instead of deleting the information out of
each form field individually). My preference would be to use a "Clear"
command button, but I don't know how to define the macro or VBA code needed.

Would anyone have any ideas on how to accomplish this? I'm new to macros
and eager to learn more about how they work. Any assistance will be
sincerely appreciated.

I advise you skip the macro step and get to VBA directly.

Are all fields on your form unbound? Then you can call a routine like this:

(AIR CODE)

dim ctl as control
on error resume next
for each ctl in Me.controls
ctl.value=null
next

Since that uses Me, it must live in the form itself. You can put the
lines directly in the Click handler for the button.

Ur?

Have the form open in Design mode. Click the button, get the properties
(View:Properties, or the Properties button in the toolbar). Select the
Events tab.
At on Click, select [Event Procedure]. Now, click the Build button (...)
Access opens the code module with the form for you, and creates an event
procedure. Paste my code there.
 
Thank you, thank you, THANK YOU!!!

The code worked perfectly, and I had a fun few minutes entering information
in the fields just so I could hit the "Clear" button and watch it all
disappear. Absolutely wonderful.

And thanks for giving me step-by-step instructions. Since I am very new to
all of this, your detailed help was exactly what I needed. I could not have
done it without you.

You are appreciated, Bas Cost Budde!!!

Ramona


Bas Cost Budde said:
Ramona said:
I have developed a form that queries for information across one or more
fields, depending on what information the user enters into the fields.

I want users to be able to clear ALL the old selection criteria on the form
before they begin a new search (instead of deleting the information out of
each form field individually). My preference would be to use a "Clear"
command button, but I don't know how to define the macro or VBA code needed.

Would anyone have any ideas on how to accomplish this? I'm new to macros
and eager to learn more about how they work. Any assistance will be
sincerely appreciated.

I advise you skip the macro step and get to VBA directly.

Are all fields on your form unbound? Then you can call a routine like this:

(AIR CODE)

dim ctl as control
on error resume next
for each ctl in Me.controls
ctl.value=null
next

Since that uses Me, it must live in the form itself. You can put the
lines directly in the Click handler for the button.

Ur?

Have the form open in Design mode. Click the button, get the properties
(View:Properties, or the Properties button in the toolbar). Select the
Events tab.
At on Click, select [Event Procedure]. Now, click the Build button (...)
Access opens the code module with the form for you, and creates an event
procedure. Paste my code there.
 
Back
Top