Doyce-
Close, but no cigar. First, I recommend against changing the SQL of qrySearch. That should be a query with no filters that's the Record Source of the form you're opening. Then the code to build your filter should look like this:
Dim strSearch As String
If Not IsNull(Me.txtMSDSID.Value) Then
strSearch = "MSDSID = '" & Me.txtMSDSID & "' "End If
If Not IsNull(Me.txtProductName.Value) Then
' If already have part of a predicate
If Len(strSearch) > 0 Then
' Add an AND
strSearch = strSearch & " AND "
End IF
strSearch = strSearch & "ProductName Like '*" & Me.txtProductName & "*' "
End If
If Not IsNull(Me.cboCategory.Value) Then
strSearch = strSearch & "ProductName Like '*" & Me.txtProductName & "*' "
End If
If Not IsNull(Me.cboCategory.Value) Then
' If already have part of a predicate
If Len(strSearch) > 0 Then
' Add an AND
strSearch = strSearch & " AND "
End If strSearch = "Category = " & Me.cboCategory & " "
---In MS_Access_Professionals@yahoogroups.com, <duanehookom@...> wrote :
End If
' … and so on.
Then do:
DoCmd.OpenForm "frmSearchResults", acFormDS, WhereCondition:=strSearch
And for the close, just do:
DoCmd.Close acForm, Me.Name
No need to do the acSaveNo.
John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications
(Paris, France)
On Nov 16, 2016, at 7:36 PM, winberry.doyce@con-way.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:
---In MS_Access_Professionals@yahoogroups.com, <duanehookom@...> wrote :
From: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com> on behalf of winberry.doyce@... [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: Wednesday, November 16, 2016 11:37 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Will Like '*' return records if the value is null?
Sent: Wednesday, November 16, 2016 11:37 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Will Like '*' return records if the value is null?
__._,_.___
Posted by: John Viescas <johnv@msn.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (6) |
Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.
.
__,_._,___
Tidak ada komentar:
Posting Komentar