By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,488 Members | 2,552 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,488 IT Pros & Developers. It's quick & easy.

HELP With Where Clause

P: n/a
I have a FIND Form with three unbound combo boxes (the cbos below). I
am able to open frmFindResults, but it is pulling up ALL records, not
those cited in strWhere.

Help!!

Thanks - HERE'S THE CODE:

=====
Private Sub butFind_Click()

'finds based on values in unbound list boxes

On Error GoTo Error_Handler:

Dim strWhere As String

If Not IsNull(Me.cboSSN) Then
strWhere = "dbo_snapshot_aplcnt.aplcnt_ssn = " & Me.cboSSN & " AND
"
End If

If Not IsNull(Me.cboPropAddress) Then
strWhere = strWhere & "dbo_snapshot_aplcnt_addr.addr_line1 = " &
Me.cboPropAddress & " AND "
End If

If Not IsNull(Me.cboDecision) Then
strWhere = strWhere & "dbo_snapshot_decsn_rsn.decsn_rsn_cd = " &
Me.cboDecision & " AND "
End If

strWhere = Left(strWhere, (Len(strWhere) - 5)) 'Removes last 'AND'

'DoCmd.OpenForm "frmFindResults", acFormDS, strWhere

Exit Sub

Error_Handler:
MsgBox Err.Number & " " & Err.Description

End Sub

May 16 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
jv
You seem to be missing a comma before the where parameter. It needs to
be:

DoCmd.OpenForm "frmFindResults", acFormDS,, strWhere

May 16 '06 #2

P: n/a
You also need to put single quotes around your text items, ie.
If Not IsNull(Me.cboSSN) Then
strWhere = "dbo_snapshot_aplcnt.aplcnt_ssn = '" & Me.cboSSN & "' AND "
End If

John

<am*******@verizon.net> wrote in message
news:11*********************@i39g2000cwa.googlegro ups.com...
I have a FIND Form with three unbound combo boxes (the cbos below). I
am able to open frmFindResults, but it is pulling up ALL records, not
those cited in strWhere.

Help!!

Thanks - HERE'S THE CODE:

=====
Private Sub butFind_Click()

'finds based on values in unbound list boxes

On Error GoTo Error_Handler:

Dim strWhere As String

If Not IsNull(Me.cboSSN) Then
strWhere = "dbo_snapshot_aplcnt.aplcnt_ssn = " & Me.cboSSN & " AND
"
End If

If Not IsNull(Me.cboPropAddress) Then
strWhere = strWhere & "dbo_snapshot_aplcnt_addr.addr_line1 = " &
Me.cboPropAddress & " AND "
End If

If Not IsNull(Me.cboDecision) Then
strWhere = strWhere & "dbo_snapshot_decsn_rsn.decsn_rsn_cd = " &
Me.cboDecision & " AND "
End If

strWhere = Left(strWhere, (Len(strWhere) - 5)) 'Removes last 'AND'

'DoCmd.OpenForm "frmFindResults", acFormDS, strWhere

Exit Sub

Error_Handler:
MsgBox Err.Number & " " & Err.Description

End Sub

May 17 '06 #3

P: n/a
Thank you both very much! I incorporated both of your suggestions and
the Find is now working.

===

May 17 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.