Cascading Combo Box Help!

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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
 
Back
Top