Basic setting form filter criter from text box

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
 
M

Marshall Barton

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 & """"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top