Connecting Tech Pros Worldwide Help | Site Map
 
 
LinkBack Thread Tools Search this Thread
  #1  
Old May 16th, 2006, 10:15 PM
amywolfie@verizon.net
Guest
 
Posts: n/a
Default HELP With Where Clause

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
Default 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
Default 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
Default Re: HELP With Where Clause

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

===

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,338 network members.