Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Im trying to make radio buttons where only one can be clicked. 1

Status
Not open for further replies.

KaayJaay

IS-IT--Management
Jul 6, 2004
64
US
Im trying to make it so that my form of radio buttons interact with each other making it so that only one can be clicked at a time, and not so all 4 can be clicked. But not sure how.

KaayJaay
 
Try creating an option group. That should do what you want. Ken

- If you are flammable and have legs, you are never blocking a fire exit.
Mitch Hedburg
 
Now, lets say i have 4 queries, i want the option group to basically pick which query is to be chosen, then i have a 2 date range text boxes. The plan is to make it so that depending on which query is ran, and the date range entered, a result is returned, but im not sure how to make a certain option button run a certain query, Any Suggestions?

KaayJaay
 
Hi

Have a button on the form to run the query, in the onclick event of that button

Select case opgMyOptionGroup
Case 1
MyQueryName = "Option1Query"
Case 2
... you get the idea ?
End Select
DoCmd.OpenQuery MyQueryCommand

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Use a case select statement behind a command button. You can add the date parameters to each query. Here is some psuedo code:

Code:
Case select [OptionGroupName]
   Case 1
      DoCmd.OpenQuery ([QueryName])
   Case 2
      DoCmd.OpenQuery ([Query2Name])
   Case 3
      DoCmd.OpenQuery ([Query3Name])
   Case 4
      DoCmd.OpenQuery ([Query4Name])
End Select

Hope this helps, Ken.


- If you are flammable and have legs, you are never blocking a fire exit.
Mitch Hedburg
 
Where do i put this code at?

KaayJaay
 
As KenReay said, in the on click event of a command button. First create a command button, then right click on it in design view and go to properties. Click on the events tab and find the box labeled "onclick". Click on the ... to the right of it and you should be brought to the vba window with the cursor in the correct spot to enter the code. Of course, substitute the names of your queries and option group.
Ken

- If you are flammable and have legs, you are never blocking a fire exit.
Mitch Hedburg
 
Alright Thanx, one more thing, now that i have entered in the correct code corresponding to my queries, when i run it, it says it cant find the query in the expression, but i dont know why.

KaayJaay
 
Can you post the code you are using? That will help diagnose what the problem may be.
Ken

- If you are flammable and have legs, you are never blocking a fire exit.
Mitch Hedburg
 
Here it is.

Private Sub Command30_Click()

Select Case [I_Rad]
Case 1
DoCmd.OpenQuery ([T T by Date])
Case 2
DoCmd.OpenQuery ([T U/Date])
Case 3
DoCmd.OpenQuery ([T h#/Date])
Case 4
DoCmd.OpenQuery ([T Dis by Date])
Case 5
DoCmd.OpenQuery ([INST Disposition])
Case 6
DoCmd.OpenQuery ([T MT by Date])
Case 7
DoCmd.OpenQuery ([T MU/Date])
Case 8
DoCmd.OpenQuery ([T #/Date])
Case 9
DoCmd.OpenQuery ([T y Date])
Case 10
DoCmd.OpenQuery ([R Disposition])
End Select
 
Hi


DoCmd.OpenQuery ([T T by Date])

is [T T By Date] the name of the query?

if yes you need


DoCmd.OpenQuery ("[T T by Date]")

but are the "[","]" realy part of the name?


DoCmd.OpenQuery ("T T by Date")

by using


DoCmd.OpenQuery ([T T by Date])

you are telling it to open the query whose name is the value of teh variable or control [T T by Date]




Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Try removing the [] and using " instead.
Select Case [I_Rad]
Case 1
DoCmd.OpenQuery ("T T by Date")

Like that. See if that helps. You can also set other options for the Openquery method. If you type a comma after the last " Access will show a list of optional entries.
Ken

- If you are flammable and have legs, you are never blocking a fire exit.
Mitch Hedburg
 
Yes, that is exactly what it was, i needed the quotes instead of the square brackets. Thanks for your help.

KaayJaay
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top