View Full Version : Space character in a field


wutaguy
10-12-2005, 04:11 PM
Hi!
I have a field that has to be 20 Characters long. Most of the time data for this field is less than 20 characters, so the remaining has to be filled with spaces to make it 20. e.g. if there is a record xyz1234567, then the rest of the record should have 10 spaces like xyz1234567ssssssssss, meaning if i click on this record then the cursor should not blink after 7 but after the spaces. Hope I am making sense.
Thanks for any input.

raskew
10-12-2005, 04:41 PM
Hi -
Lookup the Space() function in the help file. Here's how you could use it in an update query:

UPDATE YourTbl SET YourTbl.YourFld = RTrim([YourFld ]) & Space(20-Len(RTrim([YourFld ])));

Replace instances of 'YourTbl' with your table name and 'YourFld' with your field name and it should fly. Backup your database before testing ('...just in case.')

Tested in A97.

HTH - Bob