Cascading Combo Box Help!

G

Guest

With the code below I'm trying to filter a combo box on a sub form based on a
selection made on a combo box from the main form. Main form cbo is
cboOPmedsClass and sform cbo is cboOPmedsLU

I'm getting a syntax error at the end of the WHERE statement, "expected lsit
separator or ). I'm not sure how to address this and I'm not sure if I'm
referencing the controls correctly.

Any guidance would be greatly appreciated. Thanks, Rob

**********************************************************
Me.fsubOPmeds!cboOPmedsLU = Null

If IsNull(Me.cboOPmedsClass) Then
Me.fsubOPmeds!cboOPmedsLU.Enabled = False
Else
Me.fsubOPmeds!cboOPmedsLU.Enabled = True
Me.fsubOPmeds!cboOPmedsLU.Rowsource = ReplaceWhereClause
(Me.fsubOPmeds!cboOPmedsLU.Rowsource, _
"Where fldClassification = " & Me!cboPOmedsClass"
Me.fsubOPmeds!cboPOmedsLU.Requery
End If

End Sub
 
C

Carl Rapson

RobUCSD said:
With the code below I'm trying to filter a combo box on a sub form based
on a
selection made on a combo box from the main form. Main form cbo is
cboOPmedsClass and sform cbo is cboOPmedsLU

I'm getting a syntax error at the end of the WHERE statement, "expected
lsit
separator or ). I'm not sure how to address this and I'm not sure if I'm
referencing the controls correctly.

Any guidance would be greatly appreciated. Thanks, Rob

**********************************************************
Me.fsubOPmeds!cboOPmedsLU = Null

If IsNull(Me.cboOPmedsClass) Then
Me.fsubOPmeds!cboOPmedsLU.Enabled = False
Else
Me.fsubOPmeds!cboOPmedsLU.Enabled = True
Me.fsubOPmeds!cboOPmedsLU.Rowsource = ReplaceWhereClause
(Me.fsubOPmeds!cboOPmedsLU.Rowsource, _
"Where fldClassification = " & Me!cboPOmedsClass"
Me.fsubOPmeds!cboPOmedsLU.Requery
End If

End Sub

It looks like you have a double quote instead of a closing parenthesis in
your method call:

Me.fsubOPmeds!cboOPmedsLU.Rowsource = ReplaceWhereClause
(Me.fsubOPmedscboOPmedsLU.Rowsource, _
"Where fldClassification = " & Me!cboPOmedsClass)

Additionally, if the value returned for the combo box is a string instead of
a number, you'll need extra quotes around the string value as well:

Me.fsubOPmeds!cboOPmedsLU.Rowsource = ReplaceWhereClause
(Me.fsubOPmedscboOPmedsLU.Rowsource, _
"Where fldClassification = '" & Me!cboPOmedsClass & "'")

Carl Rapson
 
G

Guest

Carl, thanks for your quick response. I made the changes you suggested and
now I get a complile error "Sub or function not defined" on the line with the
* below.
(* placed to identify where the break is.) I'm not sure why this happens.
Could you help? thanks, Rob
***********************************************
Me.fsubOPmeds!cboOPmedsLU = Null

If IsNull(Me.cboOPmedsClass) Then
Me.fsubOPmeds!cboOPmedsLU.Enabled = False
Else
Me.fsubOPmeds!cboOPmedsLU.Enabled = True
Me.fsubOPmeds!cboOPmedsLU.RowSource = ReplaceWhereClause
(Me.fsubOPmeds!cboOPmedsLU.RowSource, _
"Where fldClassification = '" & *Me!cboOPmedsClass & "'")

Me.fsubOPmeds!cboPOmedsLU.Requery
End If

End Sub
 

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