473,505 Members | 14,136 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Add info from another field if present field is empty

62 New Member
I would like to have a field in my report whereby if one field is empty, information from another field is inserted as it has to be either one or the other.

I have tried
Expand|Select|Wrap|Line Numbers
  1. =IIf([RefNo] Is Null,[AdminRef])
All it seems to do is add in the AdminRef. Any help much appreciated. I'm sure I've done this before but cannot find or remember how!
Jun 22 '17 #1
18 1244
PhilOfWalton
1,430 Recognized Expert Top Contributor
What you have done is told it what to do if RefNo is Null.
You haven't told it what to do if there is a valid RefNo.

Expand|Select|Wrap|Line Numbers
  1.  IIf(IsNull([RefNo]), [AdminRef],[RefNo])
  2.  
Phil
Jun 22 '17 #2
NeoPa
32,557 Recognized Expert Moderator MVP
Or, more simply, :
Expand|Select|Wrap|Line Numbers
  1. Nz([RefNo]), [AdminRef])
Jun 22 '17 #3
glat
62 New Member
Phil, can more than one field be added or is it limited to two?
Jun 23 '17 #4
PhilOfWalton
1,430 Recognized Expert Top Contributor
Yes, but you're not helping yourself by not stating whether this is a calculated field on your report, or whether it is the underlying query.

What specifically do you want to do?

Phil
Jun 23 '17 #5
NeoPa
32,557 Recognized Expert Moderator MVP
... and with fifty posts now you should be beyond half-considered posts that waste time Glat.

If you have multiple fields you want to present in the order of whichever is come across first shows, then with fields [A], [b], [C] & [D] you would use :
Expand|Select|Wrap|Line Numbers
  1. Nz([A],Nz([b],Nz([C],[D])))
Jun 24 '17 #6
glat
62 New Member
Phil it is in an unbound text box in the report. It is not calculated.
Jun 26 '17 #7
glat
62 New Member
Sorry NeoPa.

I tried your Nz option however all I kept getting was #Type in my text box.
Jun 26 '17 #8
PhilOfWalton
1,430 Recognized Expert Top Contributor
Well, if it's not bound to a field in the report's underlying query, and it's not calculated, where is it getting any information from????

You have not answered my question "What specifically do you want to do?"

Phil
Jun 26 '17 #9
glat
62 New Member
The report is based on a query of archived files. Different files have different references and file names; TenantRef, AdminRef; FileDesc, AdminName. I am trying to have all the file references in one text box and all the file names in another text box so the report can fit on a landscape A4 page.
Jun 26 '17 #10
PhilOfWalton
1,430 Recognized Expert Top Contributor
OK, Glat

Can you post the SQL for the report's RecordSource

Phil
Jun 26 '17 #11
glat
62 New Member
Hi Phil,its
Expand|Select|Wrap|Line Numbers
  1. SELECT [Archived Files].TenantRef, [Archived Files].From, [Archived Files].To, [Archived Files].Volumes, [Archived Files].FileNo, [Archived Files].Comments, [Archived Files].FileType, Property.PropertyRef, [Archived Files].Destroyed, Property.Town, Tenant.Company, Property.AddressLine1, Property.AddressLine2, Property.AddressLine3, Property.AddressLine4, Property.PostCode, Admin.AdminName, Admin.AdminRef, [Archived Files].FileDescription, [File List].FileListName, [Archived Files].Address, [Archived Files].Town, [File List].Ref
  2. FROM [File List] RIGHT JOIN (Property RIGHT JOIN (Admin RIGHT JOIN (Tenant RIGHT JOIN [Archived Files] ON Tenant.TenantID = [Archived Files].TenantID) ON Admin.AdminRefID = [Archived Files].AdminRefID) ON Property.PropertyID = [Archived Files].PropertyID) ON [File List].FirstListNameID = [Archived Files].FileListID
  3. ORDER BY [Archived Files].FileNo;
  4.  
Jun 26 '17 #12
PhilOfWalton
1,430 Recognized Expert Top Contributor
We're getting there very, very slowly.

Now all you need to tell me is what you want to see in your text box.

I think there are 2 options

1) "ABCDEF, HIJK, LMNOPQR" where ABCDEF represents TenantRef, HIJK represents AdminRef and LMNOPQR represents PropertyRef

2) If TenantRef is Null, Show AdminRef, but if both TenantRef and AdminRef are null, Show PropertyRef.

Am I close?

Phil
Jun 26 '17 #13
glat
62 New Member
Phil, yes you are correct: if the TenantRef is Null, show FileListID, if both are Null then show AdminRef. The PropertyRef is a text box on its own.
Jun 27 '17 #14
PhilOfWalton
1,430 Recognized Expert Top Contributor
We've got there !!!!!!!

So in your SQL, before the word "FROM" add

Expand|Select|Wrap|Line Numbers
  1. IIf(Not IsNull(TenantRef), TenantRef, IIf(Not IsNull(FileListID), FileListID, Nz(AdminRef)))) AS Ref
  2.  
Phil
Jun 27 '17 #15
glat
62 New Member
Phil, sorry got caught up yesterday. Put in the SQL and receiving a message saying "Syntax error in FROM clause".
Jun 28 '17 #16
glat
62 New Member
I have however put the code in an unbound text box as
Expand|Select|Wrap|Line Numbers
  1. =IIf(Not IsNull([TenantRef]),[TenantRef],IIf(Not IsNull([FileListID]),[FileListID],Nz([AdminRef])))
and it works perfectly.

I have also used same code in another unbound text box for other fields as well.

Thank you for all your help.
Jun 28 '17 #17
NeoPa
32,557 Recognized Expert Moderator MVP
Glat:
I tried your Nz option however all I kept getting was #Type in my text box.
I must have missed this earlier.

I'm confident that using Nz() should both work and give you what you asked for. Can you post your exact attempt at following the suggestion. I suspect we may be able to help you resolve it. One thing to bear in mind using Nz() is that the type of value to use if Null is important in most cases.

Now I've caught up with the rest of the posts I can see you may not be interested in following up any longer. That's fine, but if you want to see it done with just Nz(), which would be quite sensible, then feel free to continue on.

I would guess you want something like :
Expand|Select|Wrap|Line Numbers
  1. =Nz([TenantRef],Nz([FileListID],Nz([AdminRef],'')))
If at least one of them is always guaranteed to be non-null then even :
Expand|Select|Wrap|Line Numbers
  1. =Nz([TenantRef],Nz([FileListID],[AdminRef]))
Jun 28 '17 #18
glat
62 New Member
Neopa, somehow I did not receive your last reply. I tried your
Expand|Select|Wrap|Line Numbers
  1. =Nz([TenantRef],Nz([FileListID],Nz([AdminRef],'')))
and this one did work for me as well.

Thank you.
Jul 12 '17 #19

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

Similar topics

3
12950
by: BlackFireNova | last post by:
This concerns an Access 2002 (XP) database. There are two fields, "Notes" (Memo Field) and "Notes Update" on a form (among others) which I am concerned with here. Problem: I need to be able...
6
4670
by: Greg | last post by:
I am trying to change the value of one field in my query based on the value in another. If Field 1 had the text "ONACCNT" then in Feild 2 I want the date to change to today's date. Any help would...
9
5585
by: geronimo_me | last post by:
Hi, I am atempting to compare part of a field with the whole of another field in access. Is this possible? Basically I have 2 tables with the following info: Table1 Field1 = MR.
3
1803
by: Bryan Warren via AccessMonster.com | last post by:
I am creating a new database, that will contain 2 fields that will have the same data. The DB is an inventory of computers. the fields I want to duplicate are the "serial number" and the "computer...
2
1844
by: Jan | last post by:
Hi all, I have got the following problem: User fills in excel sheet, this is loaded in Acces. After this I run a validation tool to validate the field formats. One fields is allowed to be...
7
1993
by: MN | last post by:
I am using a program called IDWorks which is reading and writing to an MS Access format database. The IDWorks program can't adjust the formatting on a displayed field in a way that we need so I...
2
9646
by: Coll | last post by:
I have a field that I would like to display on a report only if the value of another field matches a certain criteria. If it does match I need the label & the field value to display (though I'm...
3
5178
by: martin DH | last post by:
Hello, In a report, for every record, I would like a checkbox to appear checked if a certain field contains any value. The field is Client_comments. (memo field) I added a checkbox called...
2
4206
by: MyWaterloo | last post by:
Ok. I have a form with a field for a sampler's name, number, and email address. The sampler's name is selected from a combo box that references a table with name, number, and email. I want to be...
12
1958
Fspinelli
by: Fspinelli | last post by:
Me again! I am not sure how to phrase this, "but", I have to create a field that produces data in a specific format from other fields of data. Creating the table and the query was the easy...
0
7216
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
7303
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,...
0
7367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
5028
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4699
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
407
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.