By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,678 Members | 2,377 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,678 IT Pros & Developers. It's quick & easy.

set up two criteria in one command button

P: n/a
Hey,

on the form, I set up a "Search" button, which is a command button.
After a user select the city and state on the form , and hit the
"search" button, I hope another form will show up containing members
where the city and state matches what the user pick up in the previous
form. But following the wizard of command button, I only could set up
one criterea, either compare city or state. Does any one know how to do
this?
The idea is so straight forward, but without knowledge of VBA , it is
so hard for me. Thanks.

Mindy

Dec 9 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Hi Mindy,

Amend your current code so that the criteria refers to both controls:

Dim stDocName As String, stLinkCriteria As String
stDocName = "frm_FormName"
stLinkCriteria = "[fld_A]=" & "'" & Me![fld_A] & "' AND [fld_B]=" & "'"
& Me.fld_B & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit

Hope this helps

Anton

Dec 9 '05 #2

P: n/a
Base your other form on a query that contains a City field and State field.
Put the following in the criteria of the City field:
Forms!NameOfSearchForm!City
Put the following in the criteria of the State field:
Forms!NameOfSearchForm!State
Put the following code in the Click event of the button on the search form:
DoCmd.OpenForm "NameOfOtherForm"
DoCmd.Close acForm, "NameOfSearchForm"
--
PC Datasheet
Your Resource For Help With Access, Excel And Word Applications
re******@pcdatasheet.com
www.pcdatasheet.com

Over 1050 users have come from the newsgroups trusting me and requesting
help.
My fees are very reasonable.


"Mindy" <ma************@yahoo.com> wrote in message
news:11*********************@g14g2000cwa.googlegro ups.com...
Hey,

on the form, I set up a "Search" button, which is a command button.
After a user select the city and state on the form , and hit the
"search" button, I hope another form will show up containing members
where the city and state matches what the user pick up in the previous
form. But following the wizard of command button, I only could set up
one criterea, either compare city or state. Does any one know how to do
this?
The idea is so straight forward, but without knowledge of VBA , it is
so hard for me. Thanks.

Mindy

Dec 9 '05 #3

P: n/a

"PC Datasheet" <no****@nospam.spam> wrote in message
news:dq***************@newsread1.news.atl.earthlin k.net...

--
PC Datasheet


To anyone that reads this message thread, you should be aware that PC
Datasheet is notorious for advertising in newsgroups that are intended for
the *free* exchange of Access help. There are numerous consultants that
provide free expert support here. Datasheet has been repeatedly asked to
stop, but refuses.

If you would like to know more about this individual, please use the link
below.

http://home.tiscali.nl/arracom/whoissteve.html
Randy Harris

Dec 9 '05 #4

P: n/a
"PC Datasheet" <no****@nospam.spam> wrote in
news:dq***************@newsread1.news.atl.earthlin k.net:
Base your other form on a query that contains a City field and
State field. Put the following in the criteria of the City
field: Forms!NameOfSearchForm!City
Put the following in the criteria of the State field:
Forms!NameOfSearchForm!State
Put the following code in the Click event of the button on the
search form: DoCmd.OpenForm "NameOfOtherForm"
DoCmd.Close acForm, "NameOfSearchForm"

This is an example of shoddy form design. Having the originating
form's name hard-coded in the query means that the form cannot be
reused with other forms or from a menu.

Far better is to slightly alter the code the wizard created in the
button's on click event.

--
Bob Quintal

PA is y I've altered my email address.
Dec 10 '05 #5

P: n/a
Anton,

Thank you. It makes sense but doesn't work. The error message is "type
mismatch".

Dec 15 '05 #6

P: n/a
Thank you. But I think there must be a way to set up two criteria on
one button. That is why I don't like macro of ACCESS. Maybe I have to
go to VBA.

Dec 15 '05 #7

P: n/a
"Mindy" <ma************@yahoo.com> wrote in
news:11**********************@g44g2000cwa.googlegr oups.com:
Thank you. But I think there must be a way to set up two
criteria on one button. That is why I don't like macro of
ACCESS. Maybe I have to go to VBA.

yes, you must use vba.
--
Bob Quintal

PA is y I've altered my email address.
Dec 15 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.