Using values from combo box in subform

G

Guest

I am have two tables that are related by the fields CategoryID and Category_ID.

Downtime is a subform in "1 EVENT TABLE" form (the names are not of my
choosing).

My objective is to have the user select from the combo box "Cat_desc" the
value Cat_desc, which corresponds to CategoryID Both Cat_desc and Category
ID are in the table "Cat_desc". The values that show up in the combo box
"Breakdown_Description" are filtered so that the user only sees values from
the table "Breakdown_code" where Category_ID is equal to the Category ID of
the Cat_desc in the first combo box.

When using the following code, I get a box asking me to enter the parameter
value Forms!1 EVENT TABLE!Downtime.Form.Cat_desc.

Why is this?


Private Sub Breakdown_Description_Enter()
Dim strSQL As String
strSQL = "SELECT Breakdown_code.Breakdown_Description,
Breakdown_code.Breakdown_ID, Breakdown_code.Category_ID" & _
" FROM Breakdown_code " & _
"WHERE ((Breakdown_code.Category_ID) = Forms![1 EVENT
TABLE]![Downtime].Form.CategoryID)"
Me.Breakdown_Description.RowSource = strSQL
End Sub


Private Sub Cat_desc_Enter()
Dim strSQL As String
strSQL = "SELECT BREAKDOWN_CAT.Cat_desc, BREAKDOWN_CAT.CategoryID" & _
" FROM BREAKDOWN_CAT "
Me.Cat_desc.RowSource = strSQL
End Sub


Thank you for your assistance
 
G

Guest

Hey QL -- You need to move the reference to the CategoryID on the form
outside of the quotes (Watch for Wordwrap):

Private Sub Breakdown_Description_Enter()
Dim strSQL As String
strSQL = "SELECT Breakdown_code.Breakdown_Description,
Breakdown_code.Breakdown_ID, Breakdown_code.Category_ID" & _
" FROM Breakdown_code " & _
"WHERE (Breakdown_code.Category_ID = " & Forms![1 EVENT
TABLE][Downtime].Form.CategoryID & ");"
Me.Breakdown_Description.RowSource = strSQL
End Sub
 
G

Guest

Thanks for the help, xRoachx, but I am now getting the error message
"Microsoft Access can't find the form '1 EVENT TABLE'".

The name of the form is correct. What may be causing this?

Thanks

xRoachx said:
Hey QL -- You need to move the reference to the CategoryID on the form
outside of the quotes (Watch for Wordwrap):

Private Sub Breakdown_Description_Enter()
Dim strSQL As String
strSQL = "SELECT Breakdown_code.Breakdown_Description,
Breakdown_code.Breakdown_ID, Breakdown_code.Category_ID" & _
" FROM Breakdown_code " & _
"WHERE (Breakdown_code.Category_ID = " & Forms![1 EVENT
TABLE][Downtime].Form.CategoryID & ");"
Me.Breakdown_Description.RowSource = strSQL
End Sub


QuantumLeap said:
I am have two tables that are related by the fields CategoryID and Category_ID.

Downtime is a subform in "1 EVENT TABLE" form (the names are not of my
choosing).

My objective is to have the user select from the combo box "Cat_desc" the
value Cat_desc, which corresponds to CategoryID Both Cat_desc and Category
ID are in the table "Cat_desc". The values that show up in the combo box
"Breakdown_Description" are filtered so that the user only sees values from
the table "Breakdown_code" where Category_ID is equal to the Category ID of
the Cat_desc in the first combo box.

When using the following code, I get a box asking me to enter the parameter
value Forms!1 EVENT TABLE!Downtime.Form.Cat_desc.

Why is this?


Private Sub Breakdown_Description_Enter()
Dim strSQL As String
strSQL = "SELECT Breakdown_code.Breakdown_Description,
Breakdown_code.Breakdown_ID, Breakdown_code.Category_ID" & _
" FROM Breakdown_code " & _
"WHERE ((Breakdown_code.Category_ID) = Forms![1 EVENT
TABLE]![Downtime].Form.CategoryID)"
Me.Breakdown_Description.RowSource = strSQL
End Sub


Private Sub Cat_desc_Enter()
Dim strSQL As String
strSQL = "SELECT BREAKDOWN_CAT.Cat_desc, BREAKDOWN_CAT.CategoryID" & _
" FROM BREAKDOWN_CAT "
Me.Cat_desc.RowSource = strSQL
End Sub


Thank you for your assistance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top