Results 1 to 2 of 2
  1. #1
    alexandre
    Guest

    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?

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 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")
    With oRecordSet
    Do While Not .EOF
    Me.ProjCB.AddItem .Fields("Project").Value
    .MoveNext
    Loop
    .Close
    End With</pre>

    Andrew Lockton, Chrysalis Design, Melbourne Australia

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •