PatrickStel
PatrickStel

Reputation: 49

MS Access VBA - Variables are not showing correct

Goodmorning,

I'm working in MS Access VBA to generate a automated email. But to get what I want I need some values from the database.

Table: KlantInfo
KlantID: (AutoNumber)
Voorletters: (Text)
Voorvoegsel: (Text)
Achternaam: (Text)

I'm retrieving the information by a Query that is dependent from a ID from a form

Result Query:
ID = 1
Voorletters = A.B.
Voorvoegsel = van
Achternaam = Voorbeeld

When I got the return im doing the following in VBA.

Code:
varVoor = rs!Voorletters
varMidden = rs!Voorvoegsel
varEind = rs!Achternaam

varNaam = varVoor & " " & varMidden & " " & varEind

MsgBox varNaam

Ive suspected this outcome: A.B. van Voorbeeld However this is the outcome im getting:

A.B. 
van Voorbeeld.

That outcome is also going to the mail.

At first I thought the problem was the dot after B. but that aint it, cause ive used the replace function to replace the dot with a space but still the same outcome.

Do you got any tips or advise?

Kind regards, Patrick

Upvotes: 0

Views: 41

Answers (1)

Rick
Rick

Reputation: 322

Not sure what is the root cause but I think you could try the following:

varNaam = Replace(Replace(varVoor & " " & varMidden & " " & varEind, Chr(13), ""), Chr(10), "")

Upvotes: 1

Related Questions