473,395 Members | 1,464 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,395 software developers and data experts.

Query criteria based on 2 different form controls

I have a query where each customer has an [ID1] or [ID2]. Sometimes
both fields for a customer are populated, but if [ID1] is null, then
[ID2] will be populated and vice versa. I have a form,
[frmEligibility], where I select a value for [cboID1] from a combo
box. In my query I set the criteria for [ID1] to
[Forms].[frmEligibility].[cboID1]. My query finds the proper values
for [ID1].

Now I also want to find the values if I select a value for [cboID2] in
a separate combo box. In both controls, OnChange, I set the value of
the opposite control = "" so only one control has a value at one time.
In my query I want to find the record based on the control that is
populated. If [cboID1] = "", I don't want any criteria for [ID1] in
the query and [ID2] should be equal to [cboID2].

I set the criteria for the [ID1] field to:
IIf([Forms].[frmEligibility].[cboID1]<>"",[Forms].[
frmEligibility].[cboID1])
I set the criteria for the [ID2] field to:
IIf([Forms].[frmEligibility].[cboID2]<>"",[Forms].[
frmEligibility].[cboID2])

This does not work and I want [cboID1] and [cboID2] to remain on the
same form. Any suggestions?
Thanks
Nov 12 '05 #1
2 2899
neptune wrote:
I have a query where each customer has an [ID1] or [ID2]. Sometimes
both fields for a customer are populated, but if [ID1] is null, then
[ID2] will be populated and vice versa. I have a form,
[frmEligibility], where I select a value for [cboID1] from a combo
box. In my query I set the criteria for [ID1] to
[Forms].[frmEligibility].[cboID1]. My query finds the proper values
for [ID1].

Now I also want to find the values if I select a value for [cboID2] in
a separate combo box. In both controls, OnChange, I set the value of
the opposite control = "" so only one control has a value at one time.
In my query I want to find the record based on the control that is
populated. If [cboID1] = "", I don't want any criteria for [ID1] in
the query and [ID2] should be equal to [cboID2].

I set the criteria for the [ID1] field to:
IIf([Forms].[frmEligibility].[cboID1]<>"",[Forms].[
frmEligibility].[cboID1])
I set the criteria for the [ID2] field to:
IIf([Forms].[frmEligibility].[cboID2]<>"",[Forms].[
frmEligibility].[cboID2])

This does not work and I want [cboID1] and [cboID2] to remain on the
same form. Any suggestions?
Thanks


Maybe inverse the fields and the controls. If you put the form fields in
the top row (as if they were in the table) and use this as criteria:

Is Null or =[id1]

does that work?

--
Bas Cost Budde
http://www.heuveltop.org/BasCB
but the domain is nl

Nov 12 '05 #2
bs**********@hotmail.com (neptune) wrote in message news:<c5**************************@posting.google. com>...
I have a query where each customer has an [ID1] or [ID2]. Sometimes
both fields for a customer are populated, but if [ID1] is null, then
[ID2] will be populated and vice versa. I have a form,
[frmEligibility], where I select a value for [cboID1] from a combo
box. In my query I set the criteria for [ID1] to
[Forms].[frmEligibility].[cboID1]. My query finds the proper values
for [ID1].

Now I also want to find the values if I select a value for [cboID2] in
a separate combo box. In both controls, OnChange, I set the value of
the opposite control = "" so only one control has a value at one time.
In my query I want to find the record based on the control that is
populated. If [cboID1] = "", I don't want any criteria for [ID1] in
the query and [ID2] should be equal to [cboID2].

I set the criteria for the [ID1] field to:
IIf([Forms].[frmEligibility].[cboID1]<>"",[Forms].[
frmEligibility].[cboID1])
I set the criteria for the [ID2] field to:
IIf([Forms].[frmEligibility].[cboID2]<>"",[Forms].[
frmEligibility].[cboID2])

This does not work and I want [cboID1] and [cboID2] to remain on the
same form. Any suggestions?
Thanks


Sounds like a normalization issue! One way of dealing with this is to
use a stored query and modify the SQL based on what's been chosen.
You'd just store the query with no WHERE clause, then trim off the
semi-colon, add the valid where clause based on what's been chosen and
update the SQL property of the querydef in question. then you can
open the query. Of course, if you normalized, you'd only have one
field to query, and your problems would go away.
Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Steve | last post by:
Form FrmRestock's recordsource is QryFrmRestock. The TransactionDate field's criteria is set ats: Forms!FrmRestock!LastXDays. LastXDays on the form is a combobox where the selections are 30, 60...
4
by: James | last post by:
Dear group, Can anyone tell me how to do the following? I have a basic list of numbers in a table I want to be able to search these by letting the user type "<10" or ">=50" on a simple form...
2
by: RBohannon | last post by:
I have a report with most fields populated by a query. However, some of the fields are variable in such a way that their values cannot be queried from a table. At present the values for these...
6
by: Andy | last post by:
Hello, I am having many problems with setting up a parameter query that searches by the criteria entered or returns all records if nothing is entered. I have designed an unbound form with 3...
2
by: dkintheuk | last post by:
Hi all, Using Access 2000 on XP Pro PC. I have a form that is based on a presaved query - all fine with this. I also have a refresh button that takes the values from various unbound...
3
by: dskillingstad | last post by:
I'd appreciate any help I can get. I'm not sure what I'm doing wrong, but.... I've searched these groups for some solutions but no luck. I have an unbound form (frmSearch), with several unbound...
2
by: angie | last post by:
I need to figure out how to create a user interface to search a query, but here's the bad part...I need to account for criteria on at least 7 of the fields. Here's what I'm thinking I need to do:...
5
by: SeanCly10 | last post by:
Hi all. I don't want to sound like a complete idiot here, but I'm somewhat limited in my coding knowledge, and I need some advice and help. I'm working on a database that will eventually be used...
4
by: dizzydangler | last post by:
Hi all, I am a new Access user and just starting to get my head around some of the basic concepts, so please take it easy on me :) My company has been managing client records on excel, and I’m in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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...

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.