472,353 Members | 1,053 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 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 2835
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...
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...
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...
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...
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...
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...
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...
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...
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...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

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.