Removing blank space in the field. (1 Viewer)

aman

Registered User.
Local time
Today, 14:39
Joined
Oct 16, 2008
Messages
1,250
Hi guys

Can anyone please tell me how to remove the blank space in the field? I mean I have a table in which data is uploaded from excelsheets. And now one field in the table "Planno" stores blankspace in the begining of text.

Is there anyway I can remove the begining blankspace from all the values stored in Planno field of the table.

Please let me know.

Thanks
 

vbaInet

AWF VIP
Local time
Today, 22:39
Joined
Jan 22, 2010
Messages
26,374
The LTrim() variant should be sufficient.
 

aman

Registered User.
Local time
Today, 14:39
Joined
Oct 16, 2008
Messages
1,250
Hi guys

I have written the following code on the click event of a button that will remove the blank spaces at the begining of all the values in the field.

Code:
dim sql as string
sql="Update tblmain set Planno='"& trim(Planno) &"' where ID>1"
docmd.runsql sql

But when the above code runs then the table stores only blank values for Planno field in each record.

Any help would be much appreciated.

Thanks
 

JANR

Registered User.
Local time
Today, 23:39
Joined
Jan 21, 2009
Messages
1,623
Why do you insist on a VBA when you can just execute an update query?

Code:
UPDATE tblmain SET planno = Trim([planno]);

that said remove the delimiters and where-clause since you are going to update the hole table anyway.

Code:
Dim sql As String
sql = "Update tblmain set Planno = Trim([Planno])"
CurrentDb.Execute sql

JR
 

Users who are viewing this thread

Top Bottom