Sorry for clogging the boards!
Within my database I have a form which has two combo boxes. The first combo box is for the drainage basin of a BMP, and the second combo box is the HUC code for that drainage basin. I decided that a cascading combo box would be the easiest method to reduce operator error. My goal is to have the user select the drainage basin, and then have only one choice in the second combo box (the correct HUC code). Here's the data for the first and second combo boxes.
The fields that I want to show up are creek_name (combo box 1) and huc_name (combo box 2). My two combo boxes are named
and
This is the code I am currently using. You select a creek_name, and then - after you close the form and re-open it - the proper HUC value appears. I'm trying to understand why the form must be closed and re-opened to work.
Any help would be appreciated!
Within my database I have a form which has two combo boxes. The first combo box is for the drainage basin of a BMP, and the second combo box is the HUC code for that drainage basin. I decided that a cascading combo box would be the easiest method to reduce operator error. My goal is to have the user select the drainage basin, and then have only one choice in the second combo box (the correct HUC code). Here's the data for the first and second combo boxes.
Code:
tbl_creeks
[tab]creek_id (PK)
[tab]creek_name
tbl_hucdata
[tab]huc_id (PK)
[tab]creek_id (FK)
[tab]huc_name
The fields that I want to show up are creek_name (combo box 1) and huc_name (combo box 2). My two combo boxes are named
Code:
cbocreeks
Code:
cbohucdata
This is the code I am currently using. You select a creek_name, and then - after you close the form and re-open it - the proper HUC value appears. I'm trying to understand why the form must be closed and re-opened to work.
Code:
Private Sub cbocreeks_AfterUpdate()
Dim shucsource As String
shucsource = "SELECT [tbl_hucdata].[Autoid], [tbl_hucdata].[creek_name], [tbl_hucdata].[huc_name] " & _
"FROM tbl_hucdata " & _
"WHERE [creek_name] = " & Me.cbocreeks.Value
Me.cbohucdata.RowSource = shucsource
Me.cbohucdata.Requery
End Sub
Any help would be appreciated!