Can't pass string >255 characters to Word document with VBA

J

jhawk

Hi everyone,

I'm reposting this to see if I can get some additional help as I've been
unsuccessful at resolving this problem.

I've created a form-based application using Access that helps users
automatically fill out a Word form. For the most part, everything is working
great EXCEPT when I try to pass any string greater 255 characters in length
from Access to a Word text field using VBA. If it's shorter than 255
characters, I never have a problem, and the string passes fine. But when
greater than that, the string simply doesn't pass.

At the suggestion of another forum member, I tried to have Access write the
string to a text file and then get my Word form to read that text file, but I
think this may be even more complicated for me to do as I'm really a novice
at this.

Has anyone ever come up against this kind of problem? Is there any way
around it that doesn't involve creating a text file? I would really
appreciate some help.

Thanks,

jhawk
 
S

Stuart McCall

jhawk said:
Hi everyone,

I'm reposting this to see if I can get some additional help as I've been
unsuccessful at resolving this problem.

I've created a form-based application using Access that helps users
automatically fill out a Word form. For the most part, everything is
working
great EXCEPT when I try to pass any string greater 255 characters in
length
from Access to a Word text field using VBA. If it's shorter than 255
characters, I never have a problem, and the string passes fine. But when
greater than that, the string simply doesn't pass.

At the suggestion of another forum member, I tried to have Access write
the
string to a text file and then get my Word form to read that text file,
but I
think this may be even more complicated for me to do as I'm really a
novice
at this.

Has anyone ever come up against this kind of problem? Is there any way
around it that doesn't involve creating a text file? I would really
appreciate some help.

Thanks,

jhawk

Writing a text file from a string is real easy in VBA. To create (or
overwrite) a file called MyFile.txt, containing the contents of the string
MyString, you would write:

Dim f As Integer

f = FreeFile
Open "C:\Temp\MyFile.txt" For Binary Access Write As f
Put #f, , MyString
Close f
 
P

Pendragon

Chances are that your field in the Access form is a text field, so you are
limited to 255 char. Change the field type to Memo and you should be set to
accept and export more text.
 
D

Dale Fye

How are you "passing a string"

Does the Word document use a query and mailmerge to fill in the appropriate
sections, or some other method? If in a query, my guess is that you have a
Group By or DISTINCT clause in the query, which will automatically truncate
memo fields.

What does your code look like?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top