Connecting Tech Pros Worldwide Help | Site Map

HELP With Where Clause

amywolfie@verizon.net
Guest
 
Posts: n/a
#1: May 16 '06
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

jv
Guest
 
Posts: n/a
#2: May 16 '06

re: HELP With Where Clause


You seem to be missing a comma before the where parameter. It needs to
be:

DoCmd.OpenForm "frmFindResults", acFormDS,, strWhere

johnvon
Guest
 
Posts: n/a
#3: May 17 '06

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]


amywolfie@verizon.net
Guest
 
Posts: n/a
#4: May 17 '06

re: HELP With Where Clause


Thank you both very much! I incorporated both of your suggestions and
the Find is now working.

===

Closed Thread