View Single Post
  #3  
Old February 12th, 2010, 10:56 PM posted to microsoft.public.access.queries
Afrosheen via AccessMonster.com
external usenet poster
 
Posts: 70
Default Need help with changing query

Thanks for getting back to me Karl.
I don't remember where I got the WHERE 1=1. The list 5 is a list box with
Male and Female. What it's supposed to do is when I select the Male then it
will give me all the male personal. Then I'd select the race from the combo
box. If I want White Males then it will give me a list of the white males.

If I don't select anything then it give me a list of all personal any race,
male or female.

Where the problem is that in my tables I had fields [male] - checkbox,
[female] checkbox, & [race] textbox. Since the [male] and [female] were
either true or false. I decide to take them out and use one called [sex]. So
if I choose female then the [sex] would be false and vice versa on the male.

The (form!frmGender!list5) is the list box in my form called frmGender.

I hope that kinda explains it better.

By the way I copied and pasted your part in to the query and all I got was
females even when I selected males..


KARL DEWEY wrote:
I do not follow what you have in the WHERE 1=1 And IIf(Not
isnull(Forms!frmGender!List5),qryEmpMaster.Sex=Fo rms!
frmGender!List5,1=1) And IIf(Not isnull(Forms!frmGender!combo7),qryEmpMaster.
Race=Forms!frmGender!combo7,1=1);

Can you break it down for me? Do you want to test qryEmpMaster.Sex to match
Forms!frmGender!List5?

I am guessing but maybe this will do it for you --
WHERE qryEmpMaster.Sex Like IIf(Forms!frmGender!List5 Is Not Null,
IIF(Forms!frmGender!List5 = "Female", -1, 0), "*") AND qryEmpMaster.Race Like
IIF(Forms!frmGender!combo7 Is Not Null, Forms!frmGender!combo7,"*");

First of all, thanks for reading this.

[quoted text clipped - 17 lines]

Thanks in advance for your help. I hope I've explained it correctly.


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/201002/1