Filter based on user input

I

Irina

I have a form that has user initials as one of the text boxes, I would like
to ask the user to type in their initials and then display only records that
have
their initials, basically I want to filter the records by user initials
basing on
user input.
I have tried to set the filter in the form properties to
[DailyWork].[UserInitials] but I
dont know how to make a box to come up asking for the input. And the filter
does not work. I know I can use a query to prompt user, but I think that
there is a way
to filter in a form.
Could someone please help me out with this? I would appreciate that
thanks
 
E

Elvis72

You can create a form and place an unbound text box in the header that is
linked to the Initial Field in your table or query.

Then have your list in the detail section.

Here is a great example and includes a database you can download.

http://allenbrowne.com/ser-62.html
 
I

Irina

great example
thanks a bunch!!!

Elvis72 said:
You can create a form and place an unbound text box in the header that is
linked to the Initial Field in your table or query.

Then have your list in the detail section.

Here is a great example and includes a database you can download.

http://allenbrowne.com/ser-62.html


Irina said:
I have a form that has user initials as one of the text boxes, I would like
to ask the user to type in their initials and then display only records that
have
their initials, basically I want to filter the records by user initials
basing on
user input.
I have tried to set the filter in the form properties to
[DailyWork].[UserInitials] but I
dont know how to make a box to come up asking for the input. And the filter
does not work. I know I can use a query to prompt user, but I think that
there is a way
to filter in a form.
Could someone please help me out with this? I would appreciate that
thanks
 
A

asmenend

This example is amazing. One follow that I have that I'm hoping somebody can
help with is:

I have a combobox field in a form called Sponsor_Company where users can
select the appropriate company from a pre-defined list. If their desired
company is not in the list however, they can manually type in the company in
another field called Other_Sponsor_Company.

Currently, I have used the example posted before to filter using
Sponsor_Company only. The code is as follows:

If Not IsNull(Me.CompanySearch) Then
strWhere = strWhere & "([Sponsor_Company] = """ & Me.CompanySearch &
""") AND "
End If

What would I need to add to this code to properly return those records where
the user entered search criteria appears in either Sponsor_Company or
Other_Sponsor_Company?


Thanks so much in advance!!
 
D

Douglas J. Steele

If there's only going to be a value in one or the other, you could use:

If Not IsNull(Me.CompanySearch) Then
strWhere = strWhere & "([Sponsor_Company] = """ & _
Me.CompanySearch & """) AND "
End If

If Not IsNull(Me.Other_Sponsor_Company) Then
strWhere = strWhere & "([Sponsor_Company] = """ & _
Me.Other_Sponsor_Company & """) AND "
End If

If it's possible that something's selected in the combo box, but you want to
override it if something's selected in the text box, use

If Not IsNull(Me.Other_Sponsor_Company) Then
strWhere = strWhere & "([Sponsor_Company] = """ & _
Me.Other_Sponsor_Company & """) AND "
Else
If Not IsNull(Me.CompanySearch) Then
strWhere = strWhere & "([Sponsor_Company] = """ & _
Me.CompanySearch & """) AND "
End If
End If


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


asmenend said:
This example is amazing. One follow that I have that I'm hoping somebody
can
help with is:

I have a combobox field in a form called Sponsor_Company where users can
select the appropriate company from a pre-defined list. If their desired
company is not in the list however, they can manually type in the company
in
another field called Other_Sponsor_Company.

Currently, I have used the example posted before to filter using
Sponsor_Company only. The code is as follows:

If Not IsNull(Me.CompanySearch) Then
strWhere = strWhere & "([Sponsor_Company] = """ & Me.CompanySearch
&
""") AND "
End If

What would I need to add to this code to properly return those records
where
the user entered search criteria appears in either Sponsor_Company or
Other_Sponsor_Company?


Thanks so much in advance!!


Irina said:
I have a form that has user initials as one of the text boxes, I would
like
to ask the user to type in their initials and then display only records
that
have
their initials, basically I want to filter the records by user initials
basing on
user input.
I have tried to set the filter in the form properties to
[DailyWork].[UserInitials] but I
dont know how to make a box to come up asking for the input. And the
filter
does not work. I know I can use a query to prompt user, but I think that
there is a way
to filter in a form.
Could someone please help me out with this? I would appreciate that
thanks
 

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