Form Filter by Selection used in combo box Row Source

J

John F

I have a form containing an unbound combo box that is used to select the
record displayed on the form. Also on the form are several other combo boxes
that use lookup tables and display text fields from the lookup tables.

If the user uses Filter by Selection and has focus on one of these combo
boxes, I would like to use the same filter to limit the information in the
unbound combo box used to select the record.

I have code that builds an SQL statement for the unbound combo boxes
RowSource:

Private Sub Form_Current()
Dim strSQL1, strSQL2 As String
strSQL1 = "SELECT tblCdrls.chrSeqNo, " _
& "tblCdrls.chrTitle , tblCdrls.chrSubtitle " _
& "FROM tblCdrls"
strSQL2 = " ORDER BY tblCdrls.chrSeqNo;"
If Len(Nz(Me.Filter)) > 0 Then
strSQL1 = strSQL1 & " WHERE " & Me.Filter
End If
strSQL1 = strSQL1 & strSQL2

If Me.cboCdlrfind.RowSource <> strSQL1 Then
Me.cboCdlrfind.RowSource = strSQL1
Me.cboCdlrfind.Requery
End If
End Sub

If the combo box used for the Filter by Selection, the form filter is:

((Lookup_cboContractID.chrContract="DO 3"))

This does not work with my code as it is not recognized as a valid WHERE
clause. Any suggestions on how to use the form’s filter property to filter
the record selection combo box?

Thanks,

John
 

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