Results 1 to 2 of 2
2001-07-30, 20:30 #1alexandreGuest
POPULATING COMBOBOX FROM A DATABASE (WORD 2000)
how do I populate a combobox with data from a datasource outside of word.?
When I create a User form and the combobox,
what code do I use and where do I put this code?
2001-07-30, 22:02 #2
- Join Date
- Jan 2001
- Melbourne, Victoria, Australia
- Thanked 280 Times in 257 Posts
Re: POPULATING COMBOBOX FROM A DATABASE (WORD 2000)
You will need to do some research to learn about user forms and code locations. The best site I know of with samples is <A target="_blank" HREF=http://www.ulster.net/~hfeddema/CodeSamples.htm> Helen Feddema's samples page.</A>
The following code is a method that works fine with the datasource being an unprotected Access 97 file into a Word 97 combo box. It is located in the UserForm_Initialize event in the Forms code window (press F7 when designing the form). This location allows it to run whenever the form is opened.
<pre>'Now use the database to get these fields defaults
Set oWorkspace = CreateWorkspace(Name:="JetWorkspace", _
UserName:="admin", Password:="", UseType:=dbUseJet)
Set oDatabase = oWorkspace.OpenDatabase(sDB)
'add projects from the database
Set oRecordSet = oDatabase.OpenRecordset _
("SELECT Project FROM tblProject ORDER BY Project")
Do While Not .EOF
Andrew Lockton, Chrysalis Design, Melbourne Australia