Help with Macro & UserForms

C

Chris

I'm not getting the result I'm looking for. Real quick background: I have
a form in access with a command button to click and open a word document and
fill in some data from access into the document at bookmarks. The issue
arrises because the word document has a user form that opens on document
open. The data from access doesn't populate into word until the user form is
filled out or cancelled, so the data from access doesn't appear in the
appropriate fields on the user form. Now if you close the user form, the
data from access appears in the document. Then if you open the user form
right away again, the data is there in the user form.

I need a solution to this. How can I get the data from access to populate
into the word document before the user form opens without disabling the user
form?

I'm thinking some sort of macro checking where the document is opened from:

If IsOpenedFrom (access) then
end
else
userform1.show
end if

Or a macro to check whether or not that access database is open:

If IsOpen ("c:\db1.mdb") then
end
else
userform1.show
end if

Is there a better way of doing this, or should I go with the If/Then macro
on the open of the word document?

Any ideas? Otherwise, I need some help with the IsOpenedFrom macro, or
IsOpen macro, since I can't get either of those to work either.

Chris
 
D

Doug Robbins - Word MVP

Move the command that opens the userform from the template into you Access
Code so that it runs after the document has been populated with the Access
data.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
C

Chris

OK, I did that & it works as I want it to if you're opening the document by
clicking the button on the access form. However, the problem is the document
is sometimes opened from the database, and sometimes not, so the user form
still needs to open when the document opens. That's the hitch to this.

Any ideas now?

Chris
 
D

Doug Robbins - Word MVP

Is it a document that is being opened or a new document that is being
created from a template, which is what I would suggest that it should be,
and in which case, it would be a simple matter to just have two templates
that are identical with the exception that one of them has an autonew macro
in it to open the form and for the other one, the form is opened by the code
in Access

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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