Solved

Add trailing spaces to a field

Posted on 2008-06-12
6
721 Views
Last Modified: 2010-04-21
How to I add trailing sapces to a field that will be exported to a .csv file
0
Comment
Question by:morang
  • 3
  • 2
6 Comments
 
LVL 44

Expert Comment

by:GRayL
ID: 21772583
You can only add trailing spaces using a query:

Update myTable set myFld = myFld & "   ";

three spaces for example
0
 

Author Comment

by:morang
ID: 21772600
will that work if the number of spaces is not the same for every record?
0
 
LVL 44

Accepted Solution

by:
GRayL earned 500 total points
ID: 21772648
If you have a length you want to create then

UPDATE myTable SET myFld = Trim(myFld) & Space(30 - Len(Trim(myFld)));
-----------------------------------------------------------------^-- length of field with trailing spaces

In no case can the actual trimmed field length exceed the length you set.
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Closing Comment

by:morang
ID: 31466685
Thank you for your help
0
 

Expert Comment

by:bmoabc
ID: 21772743
rather than writing to the table, you can also create a query that adds the spaces dynamically.

- Create a new query
- Add all the fields that you'd like exported
- replace the field(s) where you need trailing spaces with
     myFld:table.myFld & space(number of spaces)
- export new query

That way you're never writing to your original data
0
 
LVL 44

Expert Comment

by:GRayL
ID: 21772806
morang:  What bmoabc makes a lot of sense. Rather than the update to your table turn the update into a normal select query and export the the query.

bmoabc:  morang had accepted a minute before your post arrived.
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question