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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OPTION GROUP BUTTONS

Status
Not open for further replies.

Kevsim

Instructor
Apr 18, 2000
385
AU
I have set up a group option box with 3 buttons, one for ‘prod”, another for “comp” and one for “all”. When I select the prod button, only the products appear in the combo box, when comp selected, only components appear in the combo box, when all is selected all products and components are selected. The products and components are in a field called Product. My problem is – When all is selected all products and components are mixed but in alphabetic order, when prod is selected or comp is selected, the product or component is not in alphabetic order. The code for the group option is as follows –
Private Sub Frame273_AfterUpdate()
Dim SQLText, WClause
SQLText = "SELECT [Product],[Manufacturer]FROM T_Product WHERE ProdCom = "
Select Case Me![Frame273]
Case 1
WClause = Chr(34) & "Prod" & Chr(34)
Case 2
WClause = Chr(34) & "Comp" & Chr(34)
Case 3
SQLText = "SELECT [Product],[manufacturer] FROM T_Product"
WClause = ""
End Select
With Me![Combo2]
.RowSource = SQLText & WClause
.Requery
.BackColor = RGB(255, 255, 255)
End With
End Sub
How can I have the sorts in alphabetic order? Also I set the “prod” button as default (1) in the option group default value, but the “all” button (3) remains the default, why is this?
Your advise would be appreciated.
kevsim
 
You can order the results by adding an 'Order By' statement to your WClause string:

WClause = Chr(34) & "Prod" & Chr(34) & " Order By Prod"
WClause = Chr(34) & "Comp" & Chr(34) & " Order By Comp"

Don't know about the default issue!
 
As to the default issue the only thing I can think of is does the combo2 rowsource property have a value in it on form load. If so I don't beleive that any events will take place to change it to the desired rowsouce property until someone actually makes a change in the options group.

Two ways to handle this if this is the case moght be to, one set the default rowsource property to the rowsouce for the defaulted value Or two on form load force the running on the after_update event to run by calling it from the form current event/

Good Luck
ssecca
 
If you mean the default value of the option group, you have to set this at the option group level, not the level of the option button. Blank the defaul values for each of the buttons and set the default value of the option group to the appropriate number.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developer's section of the site for some helpful fundamentals.
 
MasterPO, ssecca, JeremyNYC,
I thank you all for the replies, the sorting worked fine, WClause = Chr(34) & "Prod" & Chr(34) & " Order By Prod"
For the default value, I found the answer, put in form on load,
Private Sub Form_Load()
Me![Frame273] = 1
End Sub
By changing the number you change the default.
Thank’s again.
kevsim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top