Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Basic setting form filter criter from text box

Basic setting form filter criter from text box
Fred 12/30/2008 10:13:22 PM
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

Re: Basic setting form filter criter from text box
Marshall Barton <marshbarton[ at ]wowway.com> 12/30/2008 10:43:07 PM
Fred wrote:

[Quoted Text]
>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 & """"

--
Marsh
MVP [MS Access]
Re: Basic setting form filter criteria from text box
Fred 12/31/2008 12:43:01 PM
Thanks!

Sincerely,

Fred

Home | Search | Terms | Imprint
Newsgroups Reader