Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Access Forum    Comments List
Pending Approval    Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 

Anonymous 
 
Kevin Robertson  @Reply  
           
2 years ago
You could add some spaces with either the Space or String function.

Space
    X: [FirstName] & " " & [LastName] & Space(50-Len([FirstName] & " " & [LastName])) & [Phone]

String
    Y: [FirstName] & " " & [LastName] & String(50-Len([FirstName] & " " & [LastName]), " ") & [Phone]

Note: In my example (screenshot) I have used Courier New (Monospaced Font) so the phone numbers are aligned correctly.
Kevin Robertson  @Reply  
           
2 years ago

Raffy Navarro  @Reply  
  
2 years ago
Thank you Kevin,

How would you format it, if we need to keep the fix width of the text field, example [First Name] should have 25 char, if the record is less than 25 char, then it should have space, to keep the total number of char to 25.
Richard Rost  @Reply  
          
2 years ago
Figure out it's LEN and then add that many additional spaces to it. (25-Len)
Raffy Navarro  @Reply  
  
2 years ago
The problem I am getting with Space and Len is that when the field is null it display #Error in query and #Type! in report. I want it to put a number of space if the field has no value. I concatenated fields below and I have 3 records, but the last 2 records doesn't have costcenter, so it display #Error in query and in report it shows #Type!. I want the query and report to keep the number of spaces for that field.

"2" & ([GLNo1]) & Space(10-Len([GLNo1])) & "s" & ([DebitAmt]) & Space(23-Len([DebitAmt])) & ([Fund]) & Space(10-Len([Fund])) & ([CostCenter]) & Space(10-Len([CostCenter]))

SapiText                                                                GLNo1       DebitAmtFund        CostCenter
22512080   s113                    100000    19141612132512080113.001000001914161213
#Error                                                                25120802.00        1869
#Error                                                                251208084.001845

Kevin Robertson  @Reply  
           
2 years ago
Use the IIF Function.

Using my previous example:

X: IIf(Not IsNull([FirstName]),[FirstName] & Space(20-Len([FirstName])),Space(20)) & IIf(Not IsNull([LastName]),[LastName] & Space(20-Len([LastName])),Space(20)) & IIf(Not IsNull([Phone]),[Phone] & Space(20-Len([Phone])),Space(20))
Raffy Navarro  @Reply  
  
2 years ago
Thank you.
Raffy Navarro  @Reply  
  
2 years ago
The Space()worked, but can you also do Format() with Space() to right justify it? How do you do it? - Thank you.
Kevin Robertson  @Reply  
           
2 years ago
If you want it to have a right justified appearance simply put the Space() function BEFORE the Field name.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 7/15/2026 2:07:14 PM. PLT: 0s