Re: HELP With Where Clause
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
<amywolfie@verizon.net> wrote in message
news:1147813922.937328.19720@i39g2000cwa.googlegro ups.com...[color=blue]
> 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
>[/color] |