Basic setting form filter criter from text box

  • Thread starter Thread starter Fred
  • Start date Start date
F

Fred

Experienced on Access, very very very newbie on code.

In order to learn (step 1 of 100 of figuring out Allen Browne's multi-field
form filter example) trying to do the most basic example of setting a filter
criteria; filter for exact match between user input into an unbound text box
and a field "field1"

Just to start somewhere:

Made an unbound text box named Field1InputTextBox
Made an button named "ButtonToLaunchFilter"

Put code for "on Click" event of the button as follows:

(this is the code for the entire form)

Option Compare Database

Private Sub ButtonToLaunchFilter_Click()

Me.Filter = "[Field1] = Me.Field1InputTextBox"
Me.FilterOn = True

End Sub





Did I do anything right?
What should I change / add to make it work?

Any help would be appreciated
 
Fred said:
Experienced on Access, very very very newbie on code.

In order to learn (step 1 of 100 of figuring out Allen Browne's multi-field
form filter example) trying to do the most basic example of setting a filter
criteria; filter for exact match between user input into an unbound text box
and a field "field1"

Just to start somewhere:

Made an unbound text box named Field1InputTextBox
Made an button named "ButtonToLaunchFilter"

Put code for "on Click" event of the button as follows:

(this is the code for the entire form)

Option Compare Database

Private Sub ButtonToLaunchFilter_Click()

Me.Filter = "[Field1] = Me.Field1InputTextBox"
Me.FilterOn = True

End Sub


For a number type field, that should be:

Me.Filter = "[Field1] = " & Me.Field1InputTextBox

For a Text field"

Me.Filter = "[Field1] = """ & Me.Field1InputTextBox & """"
 
Back
Top