By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,480 Members | 771 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,480 IT Pros & Developers. It's quick & easy.

How to use toggle/option buttons on a form in Acc2003

Expert 5K+
P: 8,434
Hi all.

I'm coming from a VB6 background so this is just confusing me a little. I have a form where the user can select one of a number of years to search. The selection doesn't relate directly to any particular table or field in the database, but will be used in code later to build queries.

I have tried putting a bunch of radio/option buttons in a frame, and also tried putting a bunch of toggle buttons on the form, and run into the same problem either way. How do I tell when one of them is selected, so I can change some defaults displayed on the form?

In VB6, of course, it would be a very simple matter to code behind the Click event. But the nearest events I can find for these controls are the KeyUp/Down and MouseUp/Down, which are really not what I want. For one thing, they still fire even if, for example, you press the mouse then move off the button, and so donít select it.

Any help is appreciated.
Oct 25 '06 #1
Share this Question
Share on Google+
5 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
Drag an option group onto the form from the toolbar.

Use the wizard to set up the basic group. It will allow you to assign an integer value to each option. It will default to 1, 2, 3, etc.

Put your code in the On Click event of the Frame rather than the buttons.

Then code using select case statement

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Frame1_Click()
  3.     Select Case Frame1
  4.  
  5.     Case 1
  6.         ' do something
  7.     Case 2
  8.         ' do something
  9.     Case 3
  10.         ' do something
  11.     Else
  12.         ' do something
  13.     End Select
  14.  
  15. End Sub
  16.  
  17.  
Oct 25 '06 #2

NeoPa
Expert Mod 15k+
P: 31,441
Radio buttons come within a frame.
The AfterUpdate event will trigger every time the operator changes the selection.
Oct 25 '06 #3

Expert 5K+
P: 8,434
Radio buttons come within a frame.
The AfterUpdate event will trigger every time the operator changes the selection.
Thanks to both of you. In this case I think the frame's OnClick event is the better fit for what I'm doing.
Oct 26 '06 #4

NeoPa
Expert Mod 15k+
P: 31,441
So, beaten by a quicker AND more appropriate post... MMcCarthy does it again - Grrrr.
Seriously, it's cool you've got a good answer.
Oct 26 '06 #5

Expert 5K+
P: 8,434
So, beaten by a quicker AND more appropriate post... MMcCarthy does it again - Grrrr.
Seriously, it's cool you've got a good answer.
Need to brush up on those speed-typing skills. :)
Oct 26 '06 #6

Post your reply

Sign in to post your reply or Sign up for a free account.