Populate Word UserForm Combo Box from Access

G

Guest

Does anyone know how to reference/populate a combo box which is on a userform
within a Word document.

I am trying to overcome the 25 item limit on a drop down combo box on a Word
form.

The way to do this seems to be to create a UserForm and add the combo box
onto that. - this allows more than 25 items, but i cannot see how to
populate it from within Access.

The normal combo boxes on the document I populate like this:
doc.FormFields("EmployeeName").Dropdown.ListEntries.Add Name:=rs!employeename

I can populate the combo box on the userform from a Macro in the document
itself which then gets the information from the database, but I want to do it
the other way round - populate it form within access.

Any help greatly appreciated.
 
G

Guest

You know this really has annoyed me - now anyone reading this will just see
your incorrect reply and not bother trying to help!
 
J

James A. Fortune

N. Cotton said:
Does anyone know how to reference/populate a combo box which is on a userform
within a Word document.

I am trying to overcome the 25 item limit on a drop down combo box on a Word
form.

The way to do this seems to be to create a UserForm and add the combo box
onto that. - this allows more than 25 items, but i cannot see how to
populate it from within Access.

The normal combo boxes on the document I populate like this:
doc.FormFields("EmployeeName").Dropdown.ListEntries.Add Name:=rs!employeename

I can populate the combo box on the userform from a Macro in the document
itself which then gets the information from the database, but I want to do it
the other way round - populate it form within access.

Any help greatly appreciated.

One way is to use a Reference within Access to the Excel Object Library.
The code in Access will be quite similar to your Excel Macro code, but
there might be some differences. For example,

ChDir "C:\"
Workbooks.Open FileName:="C:\Book1.xls"

might become:

strFileName = "C:\Book1.xls"
objXL.Workbooks.Open(strFileName)

Access doesn't seem to do well with :=. Also, it's important to
reference everything from the top of the object model (or from an object
so referenced, perhaps using With ... End With when convenient) on down.
It's similar to using full paths rather than relative paths.

Post back if you have more questions.

James A. Fortune
(e-mail address removed)
 
L

Larry Daugherty

I truly am blind in one eye and I really do have limited vision in the
other. However, re-reading (and re-re-reading) your post I interpret
it as a Word issue. I confess my ignorance as to UserForms. I've
never used them. They aren't a part of Access either.

It seems like you might be trying to use Automation to program Word
from Access. To do that you establish the references to the Word side
and manipulate the Word objects using Word code from Access. It would
also seem that you've already successfully done some of that.
But...... manipulating Word objects from Access solves Word issues,
not Access issues.

If you'll type "Automation" into your newsreader's "newsgroups" window
you'll find a couple of newsgroups. They're sometimes helpful

As to the horrible, unbearable pain and suffering you think that I may
have caused you with your Word issues, and the Herculean efforts that
will be required of you to post into an appropriate newsgroup, too
bad. Gosh, how dare anyone ever dare annoy you?

I will endeavor to spare us both a repeat of this experience. Your
name has found a place in my Bozo file. I will never see another post
from you unless it's buried in a thread from someone else that I
happen to read or unless you change your contact info. I won't go out
of my way to remember your name. There are some friendly,
intelligent, well balanced people with similar names.

FWIW I post here to help people with their Access issues, If I don't
believe I can help on an issue or don't feel motivated to do so I
usually just click on by.

HTH
 
G

Guest

:


FWIW I post here to help people with their Access issues, If I don't
believe I can help on an issue or don't feel motivated to do so I
usually just click on by.

HTH

In this case it would have been better for both of us if you had indeed just
clicked on by.
 
G

Guest

Thanks for the raply James.

I can successfully reference the form fields etc on the Word document from
within Access. What I am struggling with is referenceing fields on an
underlying userform contained in the Word document.
 
J

James A. Fortune

N. Cotton said:
Thanks for the raply James.

I can successfully reference the form fields etc on the Word document from
within Access. What I am struggling with is referenceing fields on an
underlying userform contained in the Word document.

Oops. Word -- not Excel. Even though I've never used a userform in
Word, I've accessed other things in Word like tables and found that I
was always able to take the macro code and make it run in Access. If
you can post some of the macro code you get when you record a macro that
references a userform value (perhaps by hitting Record, changing a value
on the userform and then stopping the recording), I might be able to
help you massage the macro code into Access VBA.

James A. Fortune
(e-mail address removed)
 

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