Concatenating strings with ThisDocument

E

Erik N

Hi!

Sorry about this simple problem.
I am retrieveing field names from a Access DB doing:
*********************************
(This is just for testing)
For i = 0 To (rs.Fields.Count - 1)
Debug.Print rs.Fields(i).Name
fieldName = rs.Fields(i).Name
Debug.Print Thisdocument.fieldName.Value
Next
**********************************
So obviously this doesn't work. How do I write to get to
the object I want in my last debug.print statement?

Sorry for this simple question.

BR,
Erik
 
M

Malcolm Smith

Erik

fieldName will be a string and not an object. I take it that you have
defined it as a string somewhere (it's not in your code) so all you will
have to do is:

Debug.print fieldName

Hope that this helps.

- Malc
www.dragondrop.com
 
E

Erik N

Hi Malcolm!
Sorry if I am unclear. What I am trying to do is to access
an object in the Thisdocument object model. The name of
this object is in the fieldName variable.

Example: Say fieldName is called "mytextbox" meaning I can
access it by writing ThisDocument.mytextbox

So I want to cycle through these objects using my
fieldName variable. the fieldName variable is filled with
data from an access DB.Thus:
DO UNTIL EOF
Read column name from DB
add name to fieldName variable
get the data from the Word form which has the same
name as the column field

BR,
Erik
 
M

Malcolm Smith

Erik

Ah, it comes clearer now. So what sort of objects are we talking about
here? Are they these Form Field objects?

If so then what you have to do is to go through all the form fields
looking a their names until the .Name of the form field matches the name
of the fieldName string.


In your code fieldName is a string and not an object. So, this is what
you have to compare with to locate the correct form field name.

Does this make any sense? If not, shout.

Hilsen
- Malc
www.dragondrop.com
 
W

Word Heretic

G'day "Erik N" <[email protected]>,

you'd have to write a mini 4gl. Assuming VBProject unlocked, you
directly edit the appropriate line of the vbcomponent that represents
your project and then call it.

Eg

Dim ThisOne as Variant

Set ThisOne = new UNIQUESTRING


we iterate .Lines until we have an Instr match and replace it.

Ah - the advantages of having to write your own FnR before WPs came
along :)



Hi Malcolm!
Sorry if I am unclear. What I am trying to do is to access
an object in the Thisdocument object model. The name of
this object is in the fieldName variable.

Example: Say fieldName is called "mytextbox" meaning I can
access it by writing ThisDocument.mytextbox

So I want to cycle through these objects using my
fieldName variable. the fieldName variable is filled with
data from an access DB.Thus:
DO UNTIL EOF
Read column name from DB
add name to fieldName variable
get the data from the Word form which has the same
name as the column field

BR,
Erik

Steve Hudson

Word Heretic, Sydney, Australia
Tricky stuff with Word or words for you.
wordheretic.com

If my answers r 2 terse, ask again or hassle an MVP,
at least they get recognition for it then.
Lengthy replies offlist require payment.
 

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