Hi there,
I need to populate the contents of a dropdown combo box in a form
which i have made in word 2003 using vba from an access database. i
need to know the code for establishing connectivity between the two,
as well as where to insert this code in.
Cheers,
Pats.
Perry - 16 Apr 2007 18:03 GMT
Here's some code from Word VBA, in a userform code module
hosting a listbox (Listbox1) getting populated by an MS Access table.
Dim cn as new ADODB.connection
Dim rs as new ADODb.recordset
cn.connectionstring = _
"Provider=Microsoft.Jet.oledb.4.0;" & _
"Data Source=d:\data\access\mydatabase.mdb;"
cn.open
rs.open "select * from tblMyTable", cn
If rs.recordcount < 1 then
Msgbox "No records"
Else
'This is your Word VBA listbox
Me.listbox1.columncount = rs.fields.count
me.listbox1.column = rs.getrows(rs.recordcount)
End if
rs.close: set rs = nothing
cn.close: set cn = nothing
--
Krgrds,
Perry
System:
Vista/Office Ultimate
VS2005/VSTO2005 SE
> Hi there,
> I need to populate the contents of a dropdown combo box in a form
[quoted text clipped - 3 lines]
> Cheers,
> Pats.