vjdb
05-23-2008, 08:06 AM
The idea is as follows: The first column of the external excel document contains employee names. This data is displayed in a word-userform to be precise in a listbox. I have done this via the following code:Option Explicit
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim NoOfRecords As Long
Private Sub UserForm_Initialize()
Set db = OpenDatabase("D:\schuitemaker\excel en sql\testdata.xls", False, False, "Excel 8.0")
Set rs = db.OpenRecordset("SELECT * FROM `LAND`")
With rs
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
End With
ListBox1.ColumnCount = rs.Fields.Count
ListBox1.Column = rs.GetRows(NoOfRecords)
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub But now i am stuck because i do not know how the get data which belongs to the selected employee (such as mobilenr and email) into the word document via bookmarks. This information is in the same row. Any idea how to start with this one? TIA!
gr VJDB
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim NoOfRecords As Long
Private Sub UserForm_Initialize()
Set db = OpenDatabase("D:\schuitemaker\excel en sql\testdata.xls", False, False, "Excel 8.0")
Set rs = db.OpenRecordset("SELECT * FROM `LAND`")
With rs
.MoveLast
NoOfRecords = .RecordCount
.MoveFirst
End With
ListBox1.ColumnCount = rs.Fields.Count
ListBox1.Column = rs.GetRows(NoOfRecords)
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub But now i am stuck because i do not know how the get data which belongs to the selected employee (such as mobilenr and email) into the word document via bookmarks. This information is in the same row. Any idea how to start with this one? TIA!
gr VJDB