A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Parameter query with wildcards



 
 
Thread Tools Display Modes
  #1  
Old August 26th, 2004, 02:41 PM
external usenet poster
 
Posts: n/a
Default 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  
Old August 26th, 2004, 03:27 PM
Allen Browne
external usenet poster
 
Posts: n/a
Default

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  
Old August 26th, 2004, 04:42 PM
Chuck B
external usenet poster
 
Posts: n/a
Default

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  
Old August 26th, 2004, 05:03 PM
Allen Browne
external usenet poster
 
Posts: n/a
Default

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

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

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


All times are GMT +1. The time now is 03:09 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.