|
-
Jun 12th, 2007, 09:35 AM
#1
Thread Starter
Junior Member
[RESOLVED] combo boxes restricted by combo boxes
I have a form where I have two combo boxes and i want to restrict the second combo box based on what was put in the first combo box. I've seen about 5 different websites that explain step by step how to do it, and im really really close, but don't quite have it and i hope someone can help. Right now when i click on the second combo box a screen pops up asking me the value of my first combo box, once i enter that, it restricts the second combo box, but i want to bypass the pop up screen and have it find that value automatically. Anyone know what I'm doing wrong? Thanks in advance!
-
Jun 12th, 2007, 10:25 AM
#2
Re: combo boxes restricted by combo boxes
How are you populating your comboboxes from a database ? or some other way ?
Normally if i wanted to do this i would have 1 combobox populated from a database table.
Then on Selection i would run some code to do another query with the value of the combobox in the Where clause !!
e.g - (Returns the Cities for A Selected Country)
Code:
Private sub cboCountry_Click()
If cboCountry.Text <> "" then
GetCities cboCountry.Text
End If
End Sub
Private Sub GetCities(strCountry as String)
dim StrSQL as string
strSQL = "SELECT Cities From City_Table WHERE Country = '" & strCountry & "'"
' then use you database class to connect to your database and to run your sql. This will return a Recordset which you can loop through and add the Values to your Other Combo box
End Sub
Are you using a Database or are you trying to do this some other way like with Array's or something ????
-
Jun 12th, 2007, 10:53 AM
#3
Thread Starter
Junior Member
Re: combo boxes restricted by combo boxes
Thank you for your response. my form is called frmQryClarifiers . I have the first combo box (combo24) set-up with a contact from a table called tblJobs. This table is also the one where all new data is being stored (I dont know if that will have an effect on things). in that row source I have typed SELECT [tblJobs].[Contractor] FROM tblJobs; and in the after update event i have the code
vb Code:
Private Sub Combo24_AfterUpdate()
[Forms]![frmQryClarifiers]![Combo28].Requery
[Forms]![frmQryClarifiers]![Combo28].SetFocus
End Sub
Combo28 is the second combo box. Under row source for that box i have SELECT [tblJobs].[Cntr_Addr1] FROM tblJobs WHERE ((([tblJobs]![Contractor])=frmQryClarifiers!Combo24));
Like before the problem is a window coming up that states:
Enter Parameter Value
frmQryClarifiers!Combo24
And I'm just using Access as a database to do this.
Thanks!
-
Jun 12th, 2007, 12:43 PM
#4
Thread Starter
Junior Member
Re: combo boxes restricted by combo boxes
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|