Access 2007 Trim and field text addition (1 Viewer)

BigAlMonroe

New member
Local time
Today, 16:41
Joined
Mar 11, 2013
Messages
4
Hi, I created a form letter as an Access 2007 report. I want the greeting to read, "Dear [first_name]," e.g., "Dear Alan,". The [first_name] field is bound to said field in a query. When I just use the [first_name] field, I get "Dear Alan" with no comma. I've tried to add the comma various ways: "=Trim[first_name] & ",", "=[first_name] & ,", "=Trim([first_name] & ","), etc., etc. Any addition to the basic field produces the "#Type!" error. I also created labels from the same query using "=Trim([first_name] & " " & [last_name])", and that works fine. Am I missing something? Thanks!:banghead:
 

boblarson

Smeghead
Local time
Today, 13:41
Joined
Jan 12, 2001
Messages
32,059
1. Make sure that your text box is NOT named first_name (which it likely is as that is the Access default way of naming the controls - it uses the field name it is bound to.

2. If the field is used in an expression, the name of the text box needs to be changed as mentioned in number one so I would use txtFirstName or something like that. Then you use the FIELD name in the expression (name autocorrect, unless you have wisely turned it off, will automatically change the expression to use the text box name you changed and you would need to change it back to the field name).

So,

="Dear " & [first_name] & ","

would be the correct syntax for the text box control source.
 

BigAlMonroe

New member
Local time
Today, 16:41
Joined
Mar 11, 2013
Messages
4
Hey boblarson,
Duh! So simple. In fact, this was helpful in another way: I used a label for the "Dear" instead of making part of the expression as you did! Now I know better. I also added a space between the Dear and the rest: ="Dear" & " " & [first_name] & ",".
Thanks SO much!
BigAl
 

boblarson

Smeghead
Local time
Today, 13:41
Joined
Jan 12, 2001
Messages
32,059
Hey boblarson,
Duh! So simple. In fact, this was helpful in another way: I used a label for the "Dear" instead of making part of the expression as you did! Now I know better. I also added a space between the Dear and the rest: ="Dear" & " " & [first_name] & ",".
Thanks SO much!
BigAl

You don't need to use & " " & in there. My code incorporated a space after the word DEAR

="Dear " & [first_name] & ","
 

BigAlMonroe

New member
Local time
Today, 16:41
Joined
Mar 11, 2013
Messages
4
Hmmm . . . didn't work that way for me, but I'm not surprised! :D Thanks!
 

Users who are viewing this thread

Top Bottom