M
Michael_Blue
I want to use code like the below (modified from
http://support.microsoft.com/kb/253542), but I don't want to hard code the
name of the Combo box. How to reference it by name?
ActiveDocument.FormFields(cmbName) is not working for me...
Function PopulateTestComboBox(cmbName As String)
Dim dbDatabase As Database
Dim rst As Recordset
Dim i As Integer
Set dbDatabase = OpenDatabase(strDBPath)
Set rst = dbDatabase.OpenRecordset("tbl_Tests", dbOpenSnapshot)
i = 0
Do Until rst.EOF
ActiveDocument.FormFields(cmbName).AddItem (i)
ActiveDocument.FormFields(cmbName).Column(0, i) =
rst.Fields("TestName")
'ComboBox1.AddItem (i)
'ComboBox1.Column(0, i) = rst.Fields("TestName")
rst.MoveNext
i = i + 1
Loop
End Function
http://support.microsoft.com/kb/253542), but I don't want to hard code the
name of the Combo box. How to reference it by name?
ActiveDocument.FormFields(cmbName) is not working for me...
Function PopulateTestComboBox(cmbName As String)
Dim dbDatabase As Database
Dim rst As Recordset
Dim i As Integer
Set dbDatabase = OpenDatabase(strDBPath)
Set rst = dbDatabase.OpenRecordset("tbl_Tests", dbOpenSnapshot)
i = 0
Do Until rst.EOF
ActiveDocument.FormFields(cmbName).AddItem (i)
ActiveDocument.FormFields(cmbName).Column(0, i) =
rst.Fields("TestName")
'ComboBox1.AddItem (i)
'ComboBox1.Column(0, i) = rst.Fields("TestName")
rst.MoveNext
i = i + 1
Loop
End Function