K
Kevin R
I have a Word template (dot) with a UserForm that opens and has several combo
boxes for the user to make selections. It then uses these selections to
build a letter. I've also created an Access database with tables and fields
to populate the various combo boxes on the UserForm in Word. I've managed to
figure out how to do this with 1 combo box (cboHOName) on the form and 1
table/field from Access but now want to populate the other combo boxes as
well from the other tables inside the same Access database. For example in
tblOffices I have an Address1 and Address2 field with corresponding combo
boxes (cboAddress1 & cboAddress2) on the Word UserForm and tblTitles with the
EETitle field and combo box cboEETitle. I'm just not sure how to modify my
code to incorporate these as well. Here's what I have, please help!
Private Sub UserForm_Initialize()
Dim dbDatabase As Database
Dim rsTemplates As Recordset
Dim i As Integer
Dim aResults()
'Activates the Database connection.
Set dbDatabase = OpenDatabase("K:\AcsData\ROTemplatesDB.mdb")
'Opens the Offices table.
Set rsROTemplates = dbDatabase.OpenRecordset("tblOffices", dbOpenSnapshot)
i = 0
With rsROTemplates
'Populate the combobox with the values in the cboHOName field.
Do Until .EOF
cboHOName.AddItem (i)
cboHOName.Column(0, i) = .Fields("HOName")
.MoveNext
i = i + 1
Loop
End With
End Sub
boxes for the user to make selections. It then uses these selections to
build a letter. I've also created an Access database with tables and fields
to populate the various combo boxes on the UserForm in Word. I've managed to
figure out how to do this with 1 combo box (cboHOName) on the form and 1
table/field from Access but now want to populate the other combo boxes as
well from the other tables inside the same Access database. For example in
tblOffices I have an Address1 and Address2 field with corresponding combo
boxes (cboAddress1 & cboAddress2) on the Word UserForm and tblTitles with the
EETitle field and combo box cboEETitle. I'm just not sure how to modify my
code to incorporate these as well. Here's what I have, please help!
Private Sub UserForm_Initialize()
Dim dbDatabase As Database
Dim rsTemplates As Recordset
Dim i As Integer
Dim aResults()
'Activates the Database connection.
Set dbDatabase = OpenDatabase("K:\AcsData\ROTemplatesDB.mdb")
'Opens the Offices table.
Set rsROTemplates = dbDatabase.OpenRecordset("tblOffices", dbOpenSnapshot)
i = 0
With rsROTemplates
'Populate the combobox with the values in the cboHOName field.
Do Until .EOF
cboHOName.AddItem (i)
cboHOName.Column(0, i) = .Fields("HOName")
.MoveNext
i = i + 1
Loop
End With
End Sub