A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Insert one of two fields into a new table



 
 
Thread Tools Display Modes
  #1  
Old November 24th, 2006, 04:17 PM posted to microsoft.public.access.queries
Arts
external usenet poster
 
Posts: 21
Default Insert one of two fields into a new table

I have a table A with data and want to fill another table B with data based
on certain conditions in the first table.
If Field A.Author has a value put A.Author and A.Date in feild B.Author, but
if field A.Autor2 has a value put it and and A.Date in field B.Author instead.
How do i do this?
There is one more condition I have to check in both cases: Put parantheses
round the result if it is 'Y' like this
S_Autor: IIf([A].[Parantheses]='Y';'(' & [A.Author] & [A.Date] &
')';[A.Author] & [A.Date])
I tried to use IIF inside another IIF but it did not work.
--
Thank you.
  #2  
Old November 24th, 2006, 09:12 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 110
Default Insert one of two fields into a new table



NZ(A.Author2,A.Author) will return the value in Author2 unless it is null. In
that case it will return the value in A.Author.

SO, try the following expression to see if it returns the desired value.

IIF(A.Parantheses = "Y", "'") & NZ(A.Author2,A.Author) & A.Date &
IIF(A.Parantheses = "Y", "'")

Arts wrote:

I have a table A with data and want to fill another table B with data based
on certain conditions in the first table.
If Field A.Author has a value put A.Author and A.Date in feild B.Author, but
if field A.Autor2 has a value put it and and A.Date in field B.Author instead.
How do i do this?
There is one more condition I have to check in both cases: Put parantheses
round the result if it is 'Y' like this
S_Autor: IIf([A].[Parantheses]='Y';'(' & [A.Author] & [A.Date] &
')';[A.Author] & [A.Date])
I tried to use IIF inside another IIF but it did not work.
--
Thank you.

  #3  
Old November 27th, 2006, 11:34 AM posted to microsoft.public.access.queries
Arts
external usenet poster
 
Posts: 21
Default Insert one of two fields into a new table

Thank you John, it works perfect.
--
Thank you.


John Spencer skrev:



NZ(A.Author2,A.Author) will return the value in Author2 unless it is null. In
that case it will return the value in A.Author.

SO, try the following expression to see if it returns the desired value.

IIF(A.Parantheses = "Y", "'") & NZ(A.Author2,A.Author) & A.Date &
IIF(A.Parantheses = "Y", "'")

Arts wrote:

I have a table A with data and want to fill another table B with data based
on certain conditions in the first table.
If Field A.Author has a value put A.Author and A.Date in feild B.Author, but
if field A.Autor2 has a value put it and and A.Date in field B.Author instead.
How do i do this?
There is one more condition I have to check in both cases: Put parantheses
round the result if it is 'Y' like this
S_Autor: IIf([A].[Parantheses]='Y';'(' & [A.Author] & [A.Date] &
')';[A.Author] & [A.Date])
I tried to use IIF inside another IIF but it did not work.
--
Thank you.


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:15 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.