473,416 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

set up two criteria in one command button

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
7 2079
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
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

"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
"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
Anton,

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

Dec 15 '05 #6
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: pelcovits | last post by:
I am trying to set up an unbound form to enter report criteria. I've followed the MS Office Assistance document: "Create a form to enter report criteria" which describes how to enter data (such...
4
by: meganrobertson22 | last post by:
Hi Everyone- I have a question about how to add and then use the "All" selection in a combo box. I am trying to figure out how to: (1) add "All" as a selection to a combo box and then (2)...
4
by: icony | last post by:
Hi everyone, I have this slq code slqtext = "SELECT . From total_installs, uachoisi WHERE (((.)='*afe*'));" which makes a query that only accept values containing "afe". It works perfectly.
10
by: sesling | last post by:
I have created a query that will pull information from our database for the operators. This query will pull in on average 50,000 records. The operators need to refine the search results. I have...
1
by: CanuckChuck | last post by:
Hello, This question may sound too general and confusing but I am trying to keep it simple. I have a form that managers log into to view a list of the employees reporting to them. They are...
5
by: Brett | last post by:
Hello, Is it possible to have just one criteria and have it apply to a group of queries? I am trying to create a report with the separate results of 4 queries based on a prompt for the user...
7
by: DeZZar | last post by:
Hi all, Unfortunately I am quite a novice with Access!! I've created a number of data bases for my work however becuase my skills are limited to really built in functionality and wizards my...
9
ajhayes
by: ajhayes | last post by:
Hello everyone, This is my first time posting here and I'm hoping someone can help me out. I'm a relative newbie to Access and am pretty much learning as I go along, so please bear with me. ...
9
by: nixonmg | last post by:
When the Command Button "Notify" is clicked, I am wanting to send out an email to the user with appropriate information in the email (works great), check the "Notified" check box (does not work), and...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.