View Single Post
  #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.