using multiple Y/N radio buttons to open a form

C

Chuck

I am looking for a little help using multiple radio buttons on a
dialog form. Based on the buttons a user selects, I want a form to
open using the selected parameters.

For simplicity, I have a table that has 10 fields, 3 of which are Y/N
boxes:
CAR = Y/N
House = Y/N
Kids = Y/N

On the dialog from I have three Option Buttons with the follwong
names:

Car (Option0)
House (Option1)
Kids (Option2)

I expect the user to select each radio button (either on of off).
They can open the form for all records that "Cars = Y / Kids = N /
House = Y", etc

+++++++++++++++++++++++++++++++++
On Error GoTo Err_Apps_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "TestForm"

DoCmd.OpenForm stDocName, acNormal, , "Cars = " & Option0

Exit_Apps_Click:
Exit Sub

Err_Apps_Click:
MsgBox Err.Description
Resume Exit_Apps_Click

End Sub
+++++++++++++++++++


The code above works for the "Car" button, and I can individually make
the other buttons work, but not together.

I am trying to combine the multiple selections into a single
"openform" statement for example:

DoCmd.OpenForm stDocName, acNormal, , "Cars = " & Option0 AND
"House=" &Option1 AND "Kids=" & Option2

but I can not get the syntax correct.

Any help or ideas would be appreciated.
 
J

John Spencer

Correct syntax would be as follows:

DoCmd.OpenForm stDocName, acNormal, , "Cars = " & Option0 &
" AND House=" &Option1 & " AND Kids=" & Option2

Correct logic depends on what you want to do.
--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
M

Marshall Barton

Chuck said:
I am looking for a little help using multiple radio buttons on a
dialog form. Based on the buttons a user selects, I want a form to
open using the selected parameters.

For simplicity, I have a table that has 10 fields, 3 of which are Y/N
boxes:
CAR = Y/N
House = Y/N
Kids = Y/N

On the dialog from I have three Option Buttons with the follwong
names:

Car (Option0)
House (Option1)
Kids (Option2)

I expect the user to select each radio button (either on of off).
They can open the form for all records that "Cars = Y / Kids = N /
House = Y", etc [snip]

I am trying to combine the multiple selections into a single
"openform" statement for example:

DoCmd.OpenForm stDocName, acNormal, , "Cars = " & Option0 AND
"House=" &Option1 AND "Kids=" & Option2



DoCmd.OpenForm stDocName, acNormal, , _
"Cars=" & Option0 & " AND House=" & Option1 & _
" AND Kids=" & Option2
 

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