Combo box Drop Down Selection

chellebell1689

Registered User.
Local time
Today, 02:18
Joined
Mar 23, 2015
Messages
267
Hello,

I have a form with two combo boxes, one for State and one for County. I currently have the county combo using a query to filter only the counties in the selected state. My problem is that I cannot select which county I want, it automatically goes to the one at the top of the list, even when I try typing in the county name. I've checked to make sure the form in editable and the box is not locked. I've searched for this problem, but everyone else seems to fix it with one of the two I previously mentioned. I remember having this problem before, but I can't for the life of me remember how to fix it.

Please let me know if you need any more information. Thanks in advance.

~Chellebell
 
Is there anything in the afterupdate or other event code of the county combo that might be doing this? I wonder if the code meant for the afterupdate of the state combo that was put in the county combo instead might not cause this.
 
There's no events for any updates on the box or the form.

I attached the database so you can see what's going on. I know it's a mess, I took it over to help a co-worker. All I did was make a better looking form and cleared the data she didn't need.


**EDIT**
Sorry I forgot to specify where the problem is. When you open it up, go to frmPrjectViewer. It's the State & County combo boxes I'm having problems with (really just the County).
 

Attachments

Last edited:
Are we talking of form subfrmProjectLinks?

The state is populated with a query, but the county is just by a table and shows everything, not what is related to a state? However I was able to select any value in the combo for County.?

I changed it to below

Code:
SELECT tblCounties.County_ID, tblCounties.CountyName
FROM tblCounties
WHERE (((tblCounties.State_ID)=[Forms]![subfrmProjectLinks]![tblState_ID]));

That filters the County for the correct state, but when I add code to the afterupdate event of the state to requery the county I get 'Module Not found'?

However I only have 2007, and it also produces lots of errors about later version.

Every time you change the State you need to requery the County combo to get only those counties for that state.
 
Last edited:
I modified the attached database. First I had to comment out some Login and Logout code that was missing to work with the frmProjectView Like:

Code:
Private Sub Form_Load()
  '  LogAll "IN"
End Sub

Private Sub Form_Unload(Cancel As Integer)
   ' LogAll "OUT"
End Sub

I changed the row source of the country combo to a query I created qryCountyRowSource which has this SQL:

Code:
SELECT tblCounties.County_ID, tblCounties.CountyName
FROM tblCounties
WHERE (((tblCounties.State_ID)=[forms]![frmProjectViewer]![CmbState]));

I had to modify the properties of the County combo box, i.e., the column count (3), Widths (0";0.5";0") and Bound column (1).

Finally I added a requery of the county combo in the state combo afterupdate.

Code:
Private Sub CmbState_AfterUpdate()
Me.CmbCounty.Requery
End Sub
 

Attachments

Are we talking of form subfrmProjectLinks?

The state is populated with a query, but the county is just by a table and shows everything, not what is related to a state? However I was able to select any value in the combo for County.?

I changed it to below

Code:
SELECT tblCounties.County_ID, tblCounties.CountyName
FROM tblCounties
WHERE (((tblCounties.State_ID)=[Forms]![subfrmProjectLinks]![tblState_ID]));
That filters the County for the correct state, but when I add code to the afterupdate event of the state to requery the county I get 'Module Not found'?

However I only have 2007, and it also produces lots of errors about later version.

Every time you change the State you need to requery the County combo to get only those counties for that state.

No I haven't messed with that form. The form I'm working on is frmProjectViewer
 
I modified the attached database. First I had to comment out some Login and Logout code that was missing to work with the frmProjectView Like:

Code:
Private Sub Form_Load()
  '  LogAll "IN"
End Sub

Private Sub Form_Unload(Cancel As Integer)
   ' LogAll "OUT"
End Sub
I changed the row source of the country combo to a query I created qryCountyRowSource which has this SQL:

Code:
SELECT tblCounties.County_ID, tblCounties.CountyName
FROM tblCounties
WHERE (((tblCounties.State_ID)=[forms]![frmProjectViewer]![CmbState]));
I had to modify the properties of the County combo box, i.e., the column count (3), Widths (0";0.5";0") and Bound column (1).

Finally I added a requery of the county combo in the state combo afterupdate.

Code:
Private Sub CmbState_AfterUpdate()
Me.CmbCounty.Requery
End Sub

That works! Thank you so very much!
 

Users who are viewing this thread

Back
Top Bottom