A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

option button to control form query



 
 
Thread Tools Display Modes
  #1  
Old November 5th, 2009, 08:41 PM posted to microsoft.public.access.forms
ehops
external usenet poster
 
Posts: 2
Default option button to control form query

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
  #2  
Old November 5th, 2009, 10:01 PM posted to microsoft.public.access.forms
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default option button to control form query

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;

--
Build a little, test a little.


"ehops" wrote:

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

  #3  
Old November 6th, 2009, 12:28 AM posted to microsoft.public.access.forms
Mr. B[_4_]
external usenet poster
 
Posts: 171
Default option button to control form query

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


"ehops" wrote:

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

  #4  
Old November 6th, 2009, 05:02 AM posted to microsoft.public.access.forms
ehops
external usenet poster
 
Posts: 2
Default option button to control form query

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


"Mr. B" wrote:

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


"ehops" wrote:

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

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:23 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.