Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Comparison of two boolean fields

Status
Not open for further replies.

martakeithy

Technical User
Nov 12, 2001
19
GB
Hi,
I hope someone can help me. I am using Access and writing query based upon two tables. I want to compare a boolean field from each table, the two fields are set to true/false. If both fields are true then I want to add 1 to a calculated field called total, or something similar. If the fields are not both true then I want to set the created field to 0. I don't know if these created fields have a default of 0??
If anyone can shed any light on this problem, I would appreciate their input.
Regards
Marta
 
I think:

IIF ((MyTable.Test1 = TRUE AND MyTable.Test2 = TRUE),
CalcField = CalcField + 1,
0) Terry M. Hoey
 
Thanks for the expression, I must be doing something wrong, because the query leaves out records where both fields are true, and on the table afterwards the matching fields have been awarded '0'.
I am wondering if I have put the expression into the wrong place, in addition I tend to write
![field] is this wrong??
Any suggestions?
Regards
Marta
 
No, you are right about the !... Do a favor, change the query to SQL view and then cut and paste your code here. Be easier for me or others to see what is wrong... Terry M. Hoey
 
The comparison on boolean fields.
I actually had more than one pair of fields to compare and have ended up using the switch function, and it works. Yay!
Thank you very much for your help
Regards
Marta
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top