* You also need to set the FilterOn Property to True.
* The Like is a String comparison operator and I think it should always be
used with the wildcard * or ?. Otherwise, it becomes an inefficient =.
Also, I would normally resolve the TextBox to actual value. In addition,
explicit String values must be enclosed by the String delimiter.
For example, if ID is a Numeric Field, you should use:
Forms!Form1.Filter = "[ID] = & Me.Text1
If ID is String:
Forms!Form1.Filter = "[ID] Like ""*" & Me.Text1 & "*"""
Note: to include a double-quote in a double delimited String, you need to
use 2 double-quotes. The above will result in the filter String:
[ID] Like "*ABC*"
where "ABC" is what the user enters in the TextBox. "Text1"
--
HTH
Van T. Dinh
MVP (Access)
deodev said:
I am trying this code however the dat is not being filtered - I think there
is a problem with
FORMS!FORM1.FORM.FILTER="[ID] LIKE TEXTBOX1 AND [NAME] LIKE CRITERIA2
AND [SURNAME] LIKE CRITERIA3"
I get a message box to enter the value for all the "criteria1"
t t via AccessMonster.com said:
You can use form filter to filter records at forms.
1 . create 3 textbox as textbox1 textbox2 and textbox3 and set default
vaule as "*"
2. create commandbutton with name find
3. onclick property of command button
PRIVATE SUB COMMAND1_CLICK()
DIM CRITERIA1 AS STRING, CRITERIA2 AS STRING,CRITERIA3 AS STRING
CRITERIA1 = TEXTBOX1
CRITERIA2 = TEXTBOX2
CRITERIA3 = TEXTBOX3
FORMS!FORM1.FORM.FILTER="[ID] LIKE TEXTBOX1 AND [NAME] LIKE CRITERIA2
AND [SURNAME] LIKE CRITERIA3"
FORMS!FORM1.FORM.FILTERON=TRUE
END SUB
4. create another commandbutton with name show all
5. onclick property of commandbutton2
PRIVATE SUB COMMAND2_CLICK()
FORMS!FORM1.FORM.FILTERON=FALSE
END SUB
I hope it will be usefull for you