Cascading Combo Box Error (1 Viewer)

tanyamc

Registered User.
Local time
Today, 11:40
Joined
Mar 7, 2019
Messages
43
I have two combo boxes on a form. I was trying to follow http://www.fontstuff.com/access/acctut10.htm Example 2 for single source table.

My source table is qryAdminCoFarms with columns [Admin County] and [Farm Number].

However, instead of the second combo list populating, I get a parameter request box.

I have the following in the Row Source property for cboAdminCo:

SELECT DISTINCT qryAdminCoFarms.[Admin County]
FROM qryAdminCoFarms
ORDER BY qryAdminCoFarms.[Admin County];

And I get my list of Admin Counties as expected.

I have the following in After Update property of the cboAdminCo combo box:

Private Sub cboAdminCo_AfterUpdate()
On Error Resume Next
cboFarmNo.RowSource = "Select qryAdminCoFarms " & _
"FROM qryAdminCoFarms " & _
"WHERE qryAdminCoFarms.[Admin County] = '" & cboAdminCo.Value & "' " & _
"ORDER BY qryAdminCoFarms.[Farm Number];"
End Sub

However, instead of populating my cboFarmNo with the unique farm numbers for the selected Admin Co, I get a parameter box asking for a farm number.

What do I need to fix/add? Is there another property I need to update?Thanks.

(PS My SQL also includes this code if it matters...


Private Sub cmdRun_Click()
On Error Resume Next
DoCmd.OpenQuery "qryByFarmSelect", acViewNormal, acReadOnly
DoCmd.OpenReport "rptNAP_Production_Report_Farm", acViewPreview
DoCmd.Close acQuery, "qryByFarmSelect", acSaveYes
DoCmd.Close acForm, "frmSelectByFarm"

End Sub
)
 

Attachments

  • cascading box error.png
    cascading box error.png
    41 KB · Views: 57

isladogs

MVP / VIP
Local time
Today, 18:40
Joined
Jan 14, 2017
Messages
18,209
No field name in the first row of the row source select code
 
Last edited:

tanyamc

Registered User.
Local time
Today, 11:40
Joined
Mar 7, 2019
Messages
43
:eek: :banghead: Thanks for the proofread.
 

Users who are viewing this thread

Top Bottom