Button on form to switch source query?

T

thelotus99

Hello all:

I am using Access 2007, and have a large database which is in Access
2003 format. It's a very simple DB, just one large table, a few forms,
and a few queries. What I was wondering is, is it possible to create a
radio button (or other easy to use method) that will allow me to
select different queries to use for the form. Right now, I am going
into design view and changing the form source when I want to use a
different query. Also if I could choose between queries, or going
right from the main table with no query in between, that would be
perfect. I'd like to be able to do this without closing the form.
Anyone know if this is possible?

Thanks!!
 
J

Jack Cannon

Yes. You can accomplish your objective.

Use the After_Update event of the option block to load the RecordSource with
the name of the desired query.
You will then need to execute the Requery action after the RecordSource is
loaded.

Jack Cannon
 
J

Jeanette Cunningham

Hi thelotus,
you could use a drop down that has a list of queries to choose from.
Use the after update event of the drop down to change the record source of
the form.

Another way (easy if you are familiar with subforms) is to use the drop down
to change the source object of a subform on your form.
This allows you to have several different forms that you can use as the
subform of the main form.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
D

Douglas J. Steele

Yup, it's possible.

If you're using radio buttons, put them in an Option Group, then put code in
the Option Group's AfterUpdate event.

It's as simple as

Me.RecordSource = "NameOfQuery"

or

Me.RecordSource = "SELECT Field1, Field2, Field3 FROM Table ORDER BY Field1"

I can't see a legitimate reason not to use a query.
 

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