Concatetating text fields in Access 2007

  • Thread starter Thread starter accessbuilder30 via AccessMonster.com
  • Start date Start date
A

accessbuilder30 via AccessMonster.com

I've switched from Access 2003 to Access 2007. I have fields called
CompanyName, Address, and Phone that I would like to have in seperate lines
in a single textbox and display them on a report. I used the following vb
code in Access 2003.

Private Function strFullAddress() As String

strFullAddress = CompanyName & vbNewline & Address and vbNewLine & Phone

End Function

The control source for the textbox is set to =strFullAddress()

In Access 2003, everything worked fine. In Access 2007, I get a error message.
I've tried every way I can think of to make this thing work, but it won't
work. What am I doing wrong?

Thanks
 
What error message are you getting?

Where is the function located: in a stand-alone module, or in the module
associated with the form? Either way, I think you might be better off using
Public Function.
 
It's in the form module. I've tried both Public and Private. Neither seem to
work. The error message I get comes up when I open the report. It comes up as
a parameter dialog box that says "strFullAddress" when I hit enter I get a
message in the textbox where the text should be display that says "#Name?"

What error message are you getting?

Where is the function located: in a stand-alone module, or in the module
associated with the form? Either way, I think you might be better off using
Public Function.
I've switched from Access 2003 to Access 2007. I have fields called
CompanyName, Address, and Phone that I would like to have in seperate
[quoted text clipped - 16 lines]
 
Hi,

Is this correct? I hope it's not a typo.

& Address and vbNewLine & Phone 'missing ampersand after "Address"

Should it be, "& Address & " and " & vbNewLine & Phone
 
It's a typo. Something I tend do. I thought I had the problem fixed. I
deleted the textbox and placed a new one on the form. It worked for a while,
then one time when I went to open the report I got a error message that said,
"Font Initialization Error" Now I'm back to the same old error messages. I
also seem to have some trouble with Access hanging and freezing up my
computer. Don't know if anyone else has run into this problem?
 
Hi,

Then, that's probably from the Report or from some code in a standard module.
 
What are CompanyName, Address and Phone? If they're text boxes on the form,
try using Me.CompanyName, Me.Address and Me.Phone.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


accessbuilder30 via AccessMonster.com said:
It's in the form module. I've tried both Public and Private. Neither seem
to
work. The error message I get comes up when I open the report. It comes up
as
a parameter dialog box that says "strFullAddress" when I hit enter I get a
message in the textbox where the text should be display that says "#Name?"

What error message are you getting?

Where is the function located: in a stand-alone module, or in the module
associated with the form? Either way, I think you might be better off
using
Public Function.
I've switched from Access 2003 to Access 2007. I have fields called
CompanyName, Address, and Phone that I would like to have in seperate
[quoted text clipped - 16 lines]
 
Back
Top