Frame Option buttons to control combo boxes

applevacross

Registered User.
Local time
Today, 13:12
Joined
Jul 15, 2005
Messages
17
Hi all, a newbie with novice access skills.

I'm very good with utilizing the access tools however I can only code in vb editor minimally. What I'm looking to do is have the option buttons control two combo boxes. One to search by user name and the other to search by serial #. I've created an option group with two buttons I set the default values in the combo boxes in accordance with the option buttons However, the option buttons aren't doing what they are supposed to do. I've been told I need to tweak the code for the buttons in order to make them control the combo boxes. Does anybody know what I need to do to make this happen? Ultimately the user will be able to click either of the buttons to perform a search through a single combo box.

Thanks to everyone out there for making this possible. Your expert knowledge will help me grow into an expert myself.

Thanks to all in advance! :confused:
 
to be able to use ONE combobox for selecting by EITHER Name or Serial Number, you can reuse the combo box by doing something like this, in the click event of your option group:

Code:
Dim strSQL as string

Select Case fraOptionGroup

Case 1 ' to get the customer name

strSQL = "SELECT customername FROM mycusomernametable"

Case 2 ' to get the serial number

strSQL = "SELECT serialnumber FROM myserialnumbertable"

End Select

mycomboboxname.Rowsource = strSQL
mycomboboxname.Requery
 
Ok, that is fantastic. Is the Combo box related to the option group by the default value? How do I make them work in conjunction with eachother? Thanks Bob I appreciate it.
 
The code I showed goes in the CLICK event of the OPTION GROUP that you created. The combobox is related to the option group by the code that changes the underlying query of the combobox whenever an option is selected.

The combobox's "value" (changed when you select an item from the combobox) will be what you use for whatever the combobox is being used for.

Hopefully that helps explain it.

There are several other things you can set via code for the combobox, including the number of columns displayed, size of them, etc. You can do a lot with the same controls, but just reusing them in different ways based on the value selected in the option group.
 

Users who are viewing this thread

Back
Top Bottom