473,402 Members | 2,064 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,402 software developers and data experts.

Simple contatination question for a textbox in a report

I'm getting "#Error" in a report's textbox where the control
source is the following:

=[lname] & (", "+[fname]) .

Both lname and fname are valid field names for the table assigned
as the report's recordsource. If the fname field is null I want
to ignore the comma.

"John" in the fname field and "Smith" in the lname field should
read "Smith, John" but "The Home Depot" in the lname field with
nothing (Null) in the fname field should read "The Home Depot"
rather than "The Home Depot," with the un-needed trailing comma.

I wonder what I'm doing wrong. Please advise.

Thanks!

Rich Hollenbeck
Nov 13 '05 #1
2 1306
Try

IIf(Not IsNull(FName), LName & ", " & FName, LName)

HTH

Phil
"Richard Hollenbeck" <ri****************@verizon.net> wrote in message
news:OiW%d.22006$oa6.3194@trnddc07...
I'm getting "#Error" in a report's textbox where the control
source is the following:

=[lname] & (", "+[fname]) .

Both lname and fname are valid field names for the table assigned
as the report's recordsource. If the fname field is null I want
to ignore the comma.

"John" in the fname field and "Smith" in the lname field should
read "Smith, John" but "The Home Depot" in the lname field with
nothing (Null) in the fname field should read "The Home Depot"
rather than "The Home Depot," with the un-needed trailing comma.

I wonder what I'm doing wrong. Please advise.

Thanks!

Rich Hollenbeck

Nov 13 '05 #2
Richard,

Try =Nz([lname],'') & IIf(Len([fname])>0,", " & [fname],'')

Nz() substitutes a value for a null. Very useful when working with columns
that should not be null like explicit strings or numeric columns that need
to be zero if null.

"Richard Hollenbeck" <ri****************@verizon.net> wrote in message
news:OiW%d.22006$oa6.3194@trnddc07...
I'm getting "#Error" in a report's textbox where the control
source is the following:

=[lname] & (", "+[fname]) .

Both lname and fname are valid field names for the table assigned
as the report's recordsource. If the fname field is null I want
to ignore the comma.

"John" in the fname field and "Smith" in the lname field should
read "Smith, John" but "The Home Depot" in the lname field with
nothing (Null) in the fname field should read "The Home Depot"
rather than "The Home Depot," with the un-needed trailing comma.

I wonder what I'm doing wrong. Please advise.

Thanks!

Rich Hollenbeck

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Phil Stanton | last post by:
I am trying to create a text box in Word the same height as one on a report and then fill it with text. I can "read" the position of the text box from the report OK and create a text box in Word...
1
by: PerryC | last post by:
Can someone help me accomplish the following in a MSAccess Report: 1. Check if Me.Discipline = "RN" (within the source query) 2. Then check the Me.YearOfEmployment: (again within the same source...
7
by: SueB | last post by:
Greetings. I have a report based on the following query (hang in there ... it's quite long): SELECT Year(.) AS Yr, tblEvents.eventID, tblEvents.eventname, tblEvents.eventhost,...
14
by: MLH | last post by:
I use A97. I've gotten used to reading values from textbox controls on forms, I've come to rely on it pretty heavily. My habit spills over into reports. I'm uncertain whether I can reliably read...
4
by: MLH | last post by:
I have a report and on it, a subreport control Main Report Name: rptInvoiceMain Sub Report Name: rptInvoiceSubReport SubReport Control Name: rptInvoiceSubReportCtl The...
1
by: viral123 | last post by:
Hi all I am using Crystal report and I am running my report successfully for my query but I want to make my query for one specific date. I want to get the date value from the textbox value. ...
4
by: lorirobn | last post by:
Hi, I have a report displaying items that are missing from a room. I created 2 queries, the first getting the items IN the room, and the second being an "unmatched" query that references the...
12
by: Studiotyphoon | last post by:
Hi, I have report which I need to print 3 times, but would like to have the following headings Customer Copy - Print 1 Accounts Copy - Print 2 File Copy -Print 3 I created a macro to...
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: 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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.