P
pkeegs
I have set up a word template to include a combobox as per the instructions
on the article at http://support.microsoft.com/?kbid=306258. Below is the
code I have entered per the article with my own database ("FriendsPlus") and
source field ("CarePlan") entered. The macro does not seem to recognise the
first two Dim statements ("User defined types not defined"). What needs to be
done to make the macro function.
I would also like to activate the Macro wherever I place the cursor rather
than in a Field. What changes would I need in the macro to achieve that?
Option Explicit
Private Sub UserForm_Initialize()
Dim dbDatabase As Database
Dim rsFriendsPlus As Recordset
Dim i As Integer
Dim aResults()
' This code activates the Database connection.Change
' the path to reflect your database.
Set dbDatabase = OpenDatabase("E:\Friends Plus\FriendsPlus.mdb")
' This code opens the Customers table. Change the Table
' to reflect the desired table.
Set rsFriendsPlus = dbDatabase.OpenRecordset("CarePlan", dbOpenSnapshot)
i = 0
With rsFriendsPlus
' This code populates the combo box with the values
' in the CompanyName Field.
Do Until .EOF
ComboBox1.Colum(0, i) = .Fields("CarePlan")
.MoveNext
i = i + 1
Loop
End With
End Sub
Private Sub ComboBox1_Change()
ActiveDocument.FormFields("Text1").Result = ComboBox1.Value
End Sub
Private Sub Cmdclose_Click()
End
End Sub
Regards
on the article at http://support.microsoft.com/?kbid=306258. Below is the
code I have entered per the article with my own database ("FriendsPlus") and
source field ("CarePlan") entered. The macro does not seem to recognise the
first two Dim statements ("User defined types not defined"). What needs to be
done to make the macro function.
I would also like to activate the Macro wherever I place the cursor rather
than in a Field. What changes would I need in the macro to achieve that?
Option Explicit
Private Sub UserForm_Initialize()
Dim dbDatabase As Database
Dim rsFriendsPlus As Recordset
Dim i As Integer
Dim aResults()
' This code activates the Database connection.Change
' the path to reflect your database.
Set dbDatabase = OpenDatabase("E:\Friends Plus\FriendsPlus.mdb")
' This code opens the Customers table. Change the Table
' to reflect the desired table.
Set rsFriendsPlus = dbDatabase.OpenRecordset("CarePlan", dbOpenSnapshot)
i = 0
With rsFriendsPlus
' This code populates the combo box with the values
' in the CompanyName Field.
Do Until .EOF
ComboBox1.Colum(0, i) = .Fields("CarePlan")
.MoveNext
i = i + 1
Loop
End With
End Sub
Private Sub ComboBox1_Change()
ActiveDocument.FormFields("Text1").Result = ComboBox1.Value
End Sub
Private Sub Cmdclose_Click()
End
End Sub
Regards