Connecting Tech Pros Worldwide Help | Site Map

HELP With Where Clause

  #1  
Old May 16th, 2006, 10:15 PM
amywolfie@verizon.net
Guest
 
Posts: 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

  #2  
Old May 16th, 2006, 10:25 PM
jv
Guest
 
Posts: n/a

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

  #3  
Old May 17th, 2006, 03:05 AM
johnvon
Guest
 
Posts: n/a

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]


  #4  
Old May 17th, 2006, 04:45 PM
amywolfie@verizon.net
Guest
 
Posts: n/a

re: HELP With Where Clause


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

===

Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Please Help with SQL Query Problem Darin L. Miller answers 5 July 7th, 2006 01:45 AM
Help With Sub-Forms cappelquist@gmail.com answers 3 February 8th, 2006 08:55 PM
With Clause Chris, Master of All Things Insignificant answers 27 November 21st, 2005 08:09 AM
Help with syntax for where clause vulcaned@isp.com answers 1 November 13th, 2005 10:12 AM
With clause syntax errors but how do I fix it? Phil Powell answers 22 July 20th, 2005 10:59 AM