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

Access Query Expression Help

Help, Short story is I have 2 tables. 1 for the Companies and 1 for the Employees. These are used in a Main form where the user enters the Company info with a sub form for the employees info. (1 to Many). In the Employees table which is used for the subform in the main there is an extra field (Yes/No Check box) to flag if the address is an alternate address or not and the alternate address is entered in the subform. These 2 tables produce a query for mailing letters(reports). The problem is that I can't use all the address fields from the Companies table in my mailing letters query because some of the employees have alternate addresses other than the company addresses. So what I am trying to do is create an expression or something, somewhere, where in the Mailing Query, IFF the check box field is FALSE int he Employees table then use the Companies Table address info, ELSE use the Employee Table address info. Following is something I was playing with in the mailing list query criteria.
IIF([Employee Names Table]![Is_Alt_Addr]=FALSE,[Companies Table]![BillAddress1],[Employee Names Table]![Address1])
Maybe I am not going in the right direction so if anyone has an idea my ears are open. Thanks for your time.
May 7 '07 #1
7 3200
Rabbit
12,516 Expert Mod 8TB
You wouldn't put it in the criteria, you'd put it in the Field.
May 7 '07 #2
JConsulting
603 Expert 512MB
Help, Short story is I have 2 tables. 1 for the Companies and 1 for the Employees. These are used in a Main form where the user enters the Company info with a sub form for the employees info. (1 to Many). In the Employees table which is used for the subform in the main there is an extra field (Yes/No Check box) to flag if the address is an alternate address or not and the alternate address is entered in the subform. These 2 tables produce a query for mailing letters(reports). The problem is that I can't use all the address fields from the Companies table in my mailing letters query because some of the employees have alternate addresses other than the company addresses. So what I am trying to do is create an expression or something, somewhere, where in the Mailing Query, IFF the check box field is FALSE int he Employees table then use the Companies Table address info, ELSE use the Employee Table address info. Following is something I was playing with in the mailing list query criteria.
IIF([Employee Names Table]![Is_Alt_Addr]=FALSE,[Companies Table]![BillAddress1],[Employee Names Table]![Address1])
Maybe I am not going in the right direction so if anyone has an idea my ears are open. Thanks for your time.
Your logic is sound...where are you trying to apply the criteria?

Try creating an "alias" for that iif statement (which equates to a new field in your query)

MyAdress: IIF([Employee Names Table]![Is_Alt_Addr]=FALSE,[Companies Table]![BillAddress1],[Employee Names Table]![Address1])
May 7 '07 #3
You wouldn't put it in the criteria, you'd put it in the Field.
Thanks for the reply. So I would have to create an "Alias" field in the query with the expression or put the expression in the field on the mailing forms? That would mean having an expression for every address field in every form?
May 8 '07 #4
JConsulting
603 Expert 512MB
Thanks for the reply. So I would have to create an "Alias" field in the query with the expression or put the expression in the field on the mailing forms? That would mean having an expression for every address field in every form?

The alias field would become part of the query, which I assume is the recordsource for your forms. You can then add it as a field and refer to it by name on your forms.
J
May 8 '07 #5
The alias field would become part of the query, which I assume is the recordsource for your forms. You can then add it as a field and refer to it by name on your forms.
J
Thanks, I will give it a try.
May 8 '07 #6
The alias field would become part of the query, which I assume is the recordsource for your forms. You can then add it as a field and refer to it by name on your forms.
J
Yes, it works, thanks so much. You have saved me so much time. Thanks again!
May 8 '07 #7
JConsulting
603 Expert 512MB
Yes, it works, thanks so much. You have saved me so much time. Thanks again!
Happy to help.
J
May 8 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: John Baker | last post by:
Hi: As those who have looked at this newsgroup recently will realize, I am a neophyte with Access, although I have experienced with Approach (the Lotus product). There are things I could easily...
0
by: LesM | last post by:
This is a change of behaviour between Access 2000 SP3 and Access 2002 SP3. I have Progress table that is linked via ODBC into Access using OpenLink Lite for Progress 9.0b. For over a year, using...
52
by: Neil | last post by:
We are running an Access 2000 MDB with a SQL 7 back end. Our network guy is upgrading to Windows Server 2003 and wants to upgrade Office and SQL Server at the same time. We're moving to SQL Server...
7
by: rguarnieri | last post by:
Hi! I'm trying to create a query with a boolean expression like this: select (4 and 1) as Value from Table1 this query return always -1, but when I make the same calculation in visual...
9
by: Alan Mailer | last post by:
Ok, my Access 2002 language writing skills are VERY rusty,. I would know how to do what I need using SQL Server's "Coalesce' function, but I don't have that available to me in the Access 2002...
3
by: Sheldon | last post by:
I have the following query expression - Like Format((!!)) & "/*/" & (! !) which would translate to e.g. 04/*/2007 if someone is running a report for last month. The above expression is part of a...
2
by: deanoooo812 | last post by:
I have an Access query (written in MS Access 2000 - thats all we've got - don't get me started on that topic...) for making pharmacy dispensing labels based on an extract from an automated dispensing...
1
MMcCarthy
by: MMcCarthy | last post by:
Access has a number of built-in functions which can be generally used in queries or VBA code. Some of the more common ones are: Note: anything in square brackets is optional Date Functions ...
13
by: magickarle | last post by:
Hi, I got a pass-through query (that takes about 15 mins to process) I would like to integrate variables to it. IE: something simple: Select EmplID from empl_Lst where empl_lst.timestamp between...
1
ollyb303
by: ollyb303 | last post by:
Hello, I have been using the following expression in Access as part of a statement to query an Oracle database: (Sum(CASE WHEN STATS_DAILY_SA.LOGIN_TIME > (STATS_DAILY_SA.SCHEDULED_TIME -...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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,...

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.