Option Buttons How to

  • Thread starter Peter Papadimitriou
  • Start date
P

Peter Papadimitriou

Hi there

I would like to use option buttons to as follows but don't know how.

The option buttons select a product (eg Product A, B or C)
This product is then used as the Field Criteria for a Query.
I then want to display the resultant Query in a datasheet in a subwindow.

It will work like this. When I click on Product A option button, I will
see a table of information about this product in the subwindow in datasheet
format.
Similarly when I click on Product B and Product C.

I would also like to include and option button 'Products ALL' which would
list
details about Products A,B,C at the same time.

Ideas, comments code welcome

thanks
Peter
 
A

Arvin Meyer

Easy enough to do.

1. Build an Option Group Frame with 4 choices: (All and A throughC)
2. Write your record sourch in code or use the something like the following:

SELECT MyTable.*
FROM MyTable
WHERE (((MyTable.ID) Like [Forms]![MyForm]![txtResult]));

3. Add a textbox (txtResult) to your form ... it can be hidden if you like.
4. Write some code for the AfterUpdate event of the Option Group (air code):

Sub MyOptionGroup_AfterUpdate()
Select Case MyOptionGroup
Case 1
txtResult = "*"
Case 2
txtResult = "A"
Case 3
txtResult = "B"
Case 4
txtResult = "C"
End Select
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
P

Peter Papadimitriou

Thank you for your assistant.

I tried your example below

Parts 1,3,4 work!!! However I could not get Step 2 below to work properly.

I created a new query called MyQuery with the exact SQL code as below.
From Query: When I run the query, I get an empty query result.
From Forms: When I select different option buttons MyQuery which I added as
a subform remains the same
ie an empty query.
What I need to get to work is that when I select an option eg "C" I expect a
listing of all C products in MyQuery
to appear in the form SubWindow.

Appreciate any further assistance. I'm almost there.
thanks
Peter
Arvin Meyer said:
Easy enough to do.

1. Build an Option Group Frame with 4 choices: (All and A throughC)
2. Write your record sourch in code or use the something like the
following:

SELECT MyTable.*
FROM MyTable
WHERE (((MyTable.ID) Like [Forms]![MyForm]![txtResult]));

3. Add a textbox (txtResult) to your form ... it can be hidden if you
like.
4. Write some code for the AfterUpdate event of the Option Group (air
code):

Sub MyOptionGroup_AfterUpdate()
Select Case MyOptionGroup
Case 1
txtResult = "*"
Case 2
txtResult = "A"
Case 3
txtResult = "B"
Case 4
txtResult = "C"
End Select
End Sub
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access

Peter Papadimitriou said:
Hi there

I would like to use option buttons to as follows but don't know how.

The option buttons select a product (eg Product A, B or C)
This product is then used as the Field Criteria for a Query.
I then want to display the resultant Query in a datasheet in a subwindow.

It will work like this. When I click on Product A option button, I
will
see a table of information about this product in the subwindow in datasheet
format.
Similarly when I click on Product B and Product C.

I would also like to include and option button 'Products ALL' which
would
list
details about Products A,B,C at the same time.

Ideas, comments code welcome

thanks
Peter
 
Top