Missing String Parts after a Space

karl009

Registered User.
Local time
Today, 02:25
Joined
Mar 2, 2010
Messages
55
Hi,

I have a small bit of VBA code that looks up form fields and the data within those fields is set to a string.

The problem is some of the data within those fields has a space, any data after that space is missed the full string is missing.

Code:
Dim stAppName As String
    
    Dim stEmailTo As String
    Dim stEmailCC As String
    Dim stOrderNo As String
    Dim stItemNo As String
    Dim stQty As String
    Dim stMessage As String
    
    stEmailTo = Forms![AddressBook]![Email]
    stEmailCC = Forms![AddressBook]![CC]
    stOrderNo = Forms![AddressBook]![OrderNum]
    stItemNo = Forms![AddressBook]![ItemNum]
    stQty = Forms![AddressBook]![Qty]
    stMessage = Forms![AddressBook]![Message]

The code above is how the strings are being defined and set, the ItemNum can have data in the following format "123 123 123" only the first 123 is picked up am I setting this incorrectly.

Many Thanks
Karl
 
Hi,

I have a small bit of VBA code that looks up form fields and the data within those fields is set to a string.

The problem is some of the data within those fields has a space, any data after that space is missed the full string is missing.

Code:
Dim stAppName As String
 
    Dim stEmailTo As String
    Dim stEmailCC As String
    Dim stOrderNo As String
    Dim stItemNo As String
    Dim stQty As String
    Dim stMessage As String
 
    stEmailTo = Forms![AddressBook]![Email]
    stEmailCC = Forms![AddressBook]![CC]
    stOrderNo = Forms![AddressBook]![OrderNum]
    [B][COLOR=red]stItemNo = Forms![AddressBook]![ItemNum][/COLOR][/B]
    stQty = Forms![AddressBook]![Qty]
    stMessage = Forms![AddressBook]![Message]

The code above is how the strings are being defined and set, the ItemNum can have data in the following format "123 123 123" only the first 123 is picked up am I setting this incorrectly.

Many Thanks
Karl

There is nothing special that would suppress the remaining numbers. Can i ask a stupid question? what happens to stItemNo after it has been collected? Is it passed to another form or directly to an email? would need to see further code if it is the latter. Also, have you tried adding a message box in the routine to see what is being returned? You can do'
Code:
MsgBox stItemNo

i suspect that it may be in a form field and it is not wide enough.... further info please

:)


Chars


Nidge
 
Hiya,

Thanks for the response.

Its past to a small application I wrote in C#, the remaining part of the VBA in access is the following;

Code:
stAppName = "C:\SendEmail.exe"
    
    Call Shell(stAppName & " " & stEmailTo & " " & stEmailCC & " " & stOrderNo & " " & stItemNo & " " & stQty & " " & stMessage, 1)

Many Thanks
Karl
 
So if you msgbox the exact same string, what is the return?

cheers

Nidge
 
Hiya,

The string is returned in full, this would indicate that it is a problem with the C# application that I have created to send the emails.

Thanks for the help..
Karl
 
So you use spaces as separators in your shell command , and now wonder why info separated by spaces winds up in the wrong place? Try wrapping each string in Chr(34) - perhaps your app can use that to parse the values properly then. Or some other separatores, since spaces appear inside your strings.
 
Last edited:
Hi,

That's great, wrapping the problem strings using Chr(34) solved the issue...

Many Thanks
Karl
 

Users who are viewing this thread

Back
Top Bottom