View Full Version : Truncate last Character if its "/"


Jimee
08-18-2009, 07:20 AM
I have a statement in an update query that I have gathering some data frm a table. I'd like to get the first 16 characters and if the last on is a "/" remove the "/" how is this done. Here is the statement:

UPDATE ElecTrayFitting SET ElecTrayFitting.Name = Left([ElecTrayFitting.Name],16);




Thanks,
Jimee

boblarson
08-18-2009, 07:41 AM
UPDATE ElecTrayFitting SET ElecTrayFitting.Name = IIF(Right([ElecTrayFitting].[Name],1)="/",Left([ElecTrayFitting].[Name],15),Left([ElecTrayFitting.Name],16));

And you should change the field name from NAME because that is an Access Reserved Word and a particularly nasty one at that. It will cause you all sorts of grief if you do not change it because everything in the database has a .Name property and sometimes, even with the square brackets, it will choke on it.

Jimee
08-18-2009, 07:46 AM
That did it. Thanks bunches!!!!!!!