If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Parameter query with wildcards
Instead of using the Enter Parameter Value dialog box
with the below criteria: Like "*" & [Enter description name for wildcard search:] & "*" I would like to use a text box on my frmMainSwitchboard form: Like "*" & [Forms]![frmMainSwitchboard]![txtDescript] & "*" The above provides all records within in table. If this is possibe, any assistance you could provide with syntax would be greatly appreciated. Chuck B. |
#2
|
|||
|
|||
Place an unbound text box on the form that you wish to filter.
Typically this would go into the Form Header section (View menu). In its AfterUpdate event procedure, set the Filter of the form. Example: Private Sub txtFilter_AfterUpdate() If Me.Dirty Then 'Save before filter Me.Dirty = False End If With Me.txtFilter If IsNull(.value) then 'nothing entered: show all. Me.FilterOn = False Else Me.Filter = "[SomeField] Like """*" & .Value & "*""" Me.FilterOn = True End If End With End Sub Now, as soon as the user enters something, the form filters to just the matches, and if they clear the entry, it shows all records again. -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. wrote in message ... Instead of using the Enter Parameter Value dialog box with the below criteria: Like "*" & [Enter description name for wildcard search:] & "*" I would like to use a text box on my frmMainSwitchboard form: Like "*" & [Forms]![frmMainSwitchboard]![txtDescript] & "*" The above provides all records within in table. If this is possibe, any assistance you could provide with syntax would be greatly appreciated. Chuck B. |
#3
|
|||
|
|||
Allen,
My apologies, I should have explained how I wanted to use the wildcard functionality. The criteria Like "*" & [Forms]![frmMainSwitchboard]![txtDescript]& "*" will be used in a query for a report. Thank you for your response. Chuck B. -----Original Message----- Place an unbound text box on the form that you wish to filter. Typically this would go into the Form Header section (View menu). In its AfterUpdate event procedure, set the Filter of the form. Example: Private Sub txtFilter_AfterUpdate() If Me.Dirty Then 'Save before filter Me.Dirty = False End If With Me.txtFilter If IsNull(.value) then 'nothing entered: show all. Me.FilterOn = False Else Me.Filter = "[SomeField] Like """*" & .Value & "*""" Me.FilterOn = True End If End With End Sub Now, as soon as the user enters something, the form filters to just the matches, and if they clear the entry, it shows all records again. -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. wrote in message ... Instead of using the Enter Parameter Value dialog box with the below criteria: Like "*" & [Enter description name for wildcard search:] & "*" I would like to use a text box on my frmMainSwitchboard form: Like "*" & [Forms]![frmMainSwitchboard]![txtDescript] & "*" The above provides all records within in table. If this is possibe, any assistance you could provide with syntax would be greatly appreciated. Chuck B. . |
#4
|
|||
|
|||
The most efficient solution is to apply the criteria only if needed.
This example shows how to apply a WhereCondition for the report only if there is a value, and if not to show all values (including any Null ones): Dim strWhere As String With Forms!frmMainSwitchboard!txtDescript] Then If Not IsNull(.Value) Then strWhere = "[SomeField] Like """*" & .Value & "*""" End If DoCmd.OpenReport "MyReport", acViewPreview, , strWhere End With -- Allen Browne - Microsoft MVP. Perth, Western Australia. Tips for Access users - http://allenbrowne.com/tips.html Reply to group, rather than allenbrowne at mvps dot org. "Chuck B" wrote in message ... Allen, My apologies, I should have explained how I wanted to use the wildcard functionality. The criteria Like "*" & [Forms]![frmMainSwitchboard]![txtDescript]& "*" will be used in a query for a report. Thank you for your response. Chuck B. -----Original Message----- Place an unbound text box on the form that you wish to filter. Typically this would go into the Form Header section (View menu). In its AfterUpdate event procedure, set the Filter of the form. Example: Private Sub txtFilter_AfterUpdate() If Me.Dirty Then 'Save before filter Me.Dirty = False End If With Me.txtFilter If IsNull(.value) then 'nothing entered: show all. Me.FilterOn = False Else Me.Filter = "[SomeField] Like """*" & .Value & "*""" Me.FilterOn = True End If End With End Sub Now, as soon as the user enters something, the form filters to just the matches, and if they clear the entry, it shows all records again. wrote in message ... Instead of using the Enter Parameter Value dialog box with the below criteria: Like "*" & [Enter description name for wildcard search:] & "*" I would like to use a text box on my frmMainSwitchboard form: Like "*" & [Forms]![frmMainSwitchboard]![txtDescript] & "*" The above provides all records within in table. If this is possibe, any assistance you could provide with syntax would be greatly appreciated. Chuck B. |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Calling Parameter Query With SQL | ChrisM | General Discussion | 0 | August 4th, 2004 01:07 PM |
Report Based Upon Parameter Query with Form References | Vincent DeLuca | Setting Up & Running Reports | 4 | July 19th, 2004 01:55 AM |
Using a query with a replaceable parameter as the source of a control | Hoo | Using Forms | 2 | May 30th, 2004 09:43 AM |
Using a query with a replaceable parameter as the source of a control | Hoo | Running & Setting Up Queries | 1 | May 30th, 2004 07:07 AM |