option button to control form query

E

ehops

Hello all-

I have two identical forms. They only differ by the select statement in
their queries. I would like eliminate one of the forms and use a radio
button in the footer to choose which query to use. Anyone have any
suggestions?

It seems pretty simple. I am somewhat new to Access.

Thanks for your help.

---ehops
 
K

KARL DEWEY

One method is to put both queries in a union query and adding another field
for criteria from the Option Group.
Like this --
SELECT [Fcd] AS [Field1], [Ged] AS [Field2], [Mxy] AS [Field3]
FROM Table1
WHERE [Forms]![MyChoice]![Frame4] = 1
UNION ALL SELECT [Sam] AS [Field1], [Bill] AS [Field2], [Joe] AS [Field3]
FROM Table2
WHERE [Forms]![MyChoice]![Frame4] = 2;
 
M

Mr. B

You can also use VBA code in the After Update event of the Group control to
set the desired query as the record source for your form.

Set the record source for your form to which ever query you want to use when
the form first opens.

Make the first option in the Group control to refer to the recordset from
the default query.

Set the default value of the Group control to 1.

Then in the After Update event of the Group control use code like the
following:

If Me.NameOfYourGourpControl= 1 Then
Me.RecordSource = "NameOfDefaultQuery"
Else
Me.RecordSource = "NameOfSecondQuery"
End If

-----
HTH
Mr. B
http://www.askdoctoraccess.com/
Doctor Access Downloads Page:
http://www.askdoctoraccess.com/DownloadPage.htm
 
E

ehops

Mr. B-

Thank you!!! I can't figure out how to rate this, but your reply works
perfectly. I am an 'old' programmer from an old 4GL language that has long
been shelved. I have long since migrated to the operations world. I am now
fooling around with Access to try to make the world better for an outfit that
only uses excel. I know enough about db's to be dangerous. Thank you so
much for your help!!

---ehops
 

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