My Assistant
![]() ![]() |
|
|
Apr 10 2009, 05:00 PM
Post
#1
|
|
|
UtterAccess Veteran Posts: 362 |
Hi everyone,
How can I code the RowSource of a combo box given a selection from an option group? I have attached a sample database. Obviously the code is not working. :( The latest version is also pasted below. Any help you can provide is greatly appreciated. I have not been able to adapt any code I found on this site. Thank you. Janet Private Sub grpTyp_AfterUpdate() Select Case grpTyp Case "CIL" Me.cboVer.Enabled = True Me.cboVer.RowSourceType = Table ' Me.cboVer.RowSource = "SELECT tblCilVer.CILVer" & "FROM tblCilVer" & "ORDER BY tblCilVer.CILVer;" Me.cboVer.RowSource = "SELECT tblCilVer.CILID, tblCilVer.CILVer" & "FROM tblCilVer" & "ORDER BY [CILVer];" Me.cboVer.SetFocus Case "HIL" Me.cboVer.Enabled = True Me.cboVer.RowSource = "tblHilVer" Me.cboVer.SetFocus Case "INT" Me.cboVer.Enabled = True Me.cboVer.RowSource = "SELECT [INTVer]" & "FROM tblIntVer" & "ORDER BY tblIntVer.INTVer;" Me.cboVer.SetFocus End Select End Sub
Attached File(s)
|
|
|
|
Apr 10 2009, 05:06 PM
Post
#2
|
|
|
UtterAccess VIP Posts: 3,881 From: New Zealand |
Janet,
The value of an Option Group is always a number. It is the Option Value of the selected option button. Therefore this is not possible: Case "CIL" Instead, it is probably: Case 1 Another point... The syntax of the SQL of the Row Source settings is incorrect, in that you have no spaces between the clauses. In fact, no need for the '&'s at all, e.g. Me.cboVer.RowSource = "SELECT tblCilVer.CILID, tblCilVer.CILVer FROM tblCilVer ORDER BY [CILVer]" See how you go with that. |
|
|
|
Apr 10 2009, 05:11 PM
Post
#3
|
|
|
Utter A-fishin'-ado Posts: 17,723 From: Cincinnati, Ohio, USA . . . ><((((°> |
Not to spoon feed, ... but I was working this out before Steve posted ...
Try: CODE Private Sub grpTyp_AfterUpdate() Select Case grpTyp Case 1 Me.cboVer.RowSource = "SELECT CILID, CILVer FROM tblCilVer ORDER BY CILVer" Case 2 Me.cboVer.RowSource = "SELECT HILID, HILVer FROM tblHilVer ORDER BY HILVer" Case 3 Me.cboVer.RowSource = "SELECT INTID, INTVer FROM tblIntVer ORDER BY INTVer" End Select Me.cboVer.SetFocus End Sub I'll let you work out the combo box settings on your own. (IMG:http://www.utteraccess.com/forum/style_emoticons/default/cool.gif) |
|
|
|
Apr 10 2009, 05:28 PM
Post
#4
|
|
|
UtterAccess Veteran Posts: 362 |
Thank you Steve,
I made the changes you suggested but it still does not work. Thank you for your time and instruction. Please feel free to throw any other ideas my way. I do not get any errors so I don't know where to look. v/r, Janet |
|
|
|
Apr 10 2009, 05:38 PM
Post
#5
|
|
|
UtterAccess VIP Posts: 3,881 From: New Zealand |
Janet,
Just a hint... sorry not meaning to get at you. "Does not work" does not really give us a lot to go on. If possible, it helps if you can say exactly what results you get, and exactly how this is different from what you want. Also, re-posting your modified code would be a good idea. Thanks. Anyway, Walter's suggestion any good? |
|
|
|
Apr 10 2009, 05:42 PM
Post
#6
|
|
|
UtterAccess Veteran Posts: 362 |
Thank you Walter!
Your code gave me the PK autonumber values so it was easily changed to the other column. I very much appreciate your help and time. Thank you very much Walter and Steve!! (IMG:http://www.utteraccess.com/forum/style_emoticons/default/sad.gif) v/r, Janet Here's what worked. Private Sub grpTyp_AfterUpdate() Select Case grpTyp Case 1 Me.cboVer.RowSource = "SELECT CILVer FROM tblCilVer ORDER BY CILVer" Case 2 Me.cboVer.RowSource = "SELECT HILVer FROM tblHilVer ORDER BY HILVer" Case 3 Me.cboVer.RowSource = "SELECT INTVer FROM tblIntVer ORDER BY INTVer" End Select Me.cboVer.SetFocus End Sub |
|
|
|
Apr 10 2009, 05:52 PM
Post
#7
|
|
|
UtterAccess Veteran Posts: 362 |
You're right Steve,
I should not have posted that way. I should have posted the results, compared them to what I needed, and the modified code, as you suggest. Thank you for the input. I hope to do better in the future. Yes, thanks, Walter's suggestion was good. I posted the modified code in my response to him in this thread. Thank you for your help and patience. v/r, Janet |
|
|
|
Apr 10 2009, 06:05 PM
Post
#8
|
|
|
UtterAccess VIP Posts: 3,881 From: New Zealand |
Very good, Janet. Thanks for letting us know. Best wishes for the rest of the project.
|
|
|
|
Apr 10 2009, 08:02 PM
Post
#9
|
|
|
Utter A-fishin'-ado Posts: 17,723 From: Cincinnati, Ohio, USA . . . ><((((°> |
|
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 22nd May 2013 - 03:29 PM |