using multiple Y/N radio buttons to open a form

  • Thread starter Thread starter Chuck
  • Start date Start date
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.
 
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
..
 
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
 
Back
Top