How to ignore spaces at end of a field

blackbeltrrf

Registered User.
Local time
Today, 00:42
Joined
May 10, 2007
Messages
13
I have a problem with figuring out how to ignore a variable amount of blank spaces at the end of a field. My VBA code is as follows:

Private Sub cmdGetPrint_Click()
Dim x$
Dim stAppName As String
On Error GoTo Blank
Text177.Value = "" ' this is a textbox on my form used for building string
x$ = ItemMasterAqry_ITNBR (***Here is my problem***)
y$ = "series"
L$ = Left(x, 2)
t$ = L + y
Text177.Value = "\\prnusemcffilsrv1\faslook\exe\fl32.exe "+ " \\prnusemcfilsrv1\drawings\" + t$ + "\" + x$ + ".dwg"
stAppName = Text177.Value
Call Shell(stAppName, 1)

x$ = 1
End Sub

My problem is that with the different amounts of spaces at the end of the field I am referencing from our server my string build looks something like this:

\\prnusemcffilsrv1\faslook\exe\fl32.exe\\prnusemcfilsrv1\drawings\99series\991194 (variable amount of spaces) .dwg

I need to ignore the spaces at the end and move the .dwg to right after the part number so it can find and open the drawing

Any help would be GREATLY appreciated
 
Have you tried wrapping Trim() around the variable to trim out the leading and trailing spaces?

Also you do not need the .Value and also declare your variables correctly

Dim X as String

Do not use the $ sign this is out of date now. What version of Access are you using?
 
TYVM! That works great!! I feel so stupid but thanyou again very much!
 
note that trim removes spaces at both ends of the string

there is also ltrim and rtrim to just attack one end!
 

Users who are viewing this thread

Back
Top Bottom