mojo
09-01-2000, 06:17 AM
I have the following code behind a command button:
Dim rwIndex As Integer
Dim DB As Database, RS As Recordset
Dim StartCell As Range
Dim XLApp As New Excel.Application
XLApp.Workbooks.Open ("C:jobtracker emp.xls")
Set DB = OpenDatabase("C:jobtrackerjobtracker.mdb")
Set RS = DB.OpenRecordset("jobtracker")
Set StartCell = XLApp.Worksheets(1).Range("A4")
RS.MoveFirst
For x = 0 To RS.RecordCount - 1
With StartCell
If RS.Fields("username").Value = TBUsername.Text And RS.Fields("completed").Value = "" Then
.Offset(x, 0).Value = RS.Fields("jobnumber").Value
.Offset(x, 1).Value = RS.Fields("username").Value
.Offset(x, 2).Value = RS.Fields("clientname").Value
.Offset(x, 3).Value = RS.Fields("duedate").Value
.Offset(x, 4).Value = RS.Fields("budget").Value
.Offset(x, 5).Value = RS.Fields("partner").Value
.Offset(x, 6).Value = RS.Fields("description").Value
End If
End With
RS.MoveNext
Next
RS.Close
DB.Close
XLApp.Application.Visible = True
GoTo theend
I am trying to copy individual records from a recordset (table) into rows of an excel spreadsheet. But the records refuse to copy into the s/sheet.
Does anybody have any ideas why?
Any help is much appreciated (you are doing a great job here...thanks)
Dion
Dim rwIndex As Integer
Dim DB As Database, RS As Recordset
Dim StartCell As Range
Dim XLApp As New Excel.Application
XLApp.Workbooks.Open ("C:jobtracker emp.xls")
Set DB = OpenDatabase("C:jobtrackerjobtracker.mdb")
Set RS = DB.OpenRecordset("jobtracker")
Set StartCell = XLApp.Worksheets(1).Range("A4")
RS.MoveFirst
For x = 0 To RS.RecordCount - 1
With StartCell
If RS.Fields("username").Value = TBUsername.Text And RS.Fields("completed").Value = "" Then
.Offset(x, 0).Value = RS.Fields("jobnumber").Value
.Offset(x, 1).Value = RS.Fields("username").Value
.Offset(x, 2).Value = RS.Fields("clientname").Value
.Offset(x, 3).Value = RS.Fields("duedate").Value
.Offset(x, 4).Value = RS.Fields("budget").Value
.Offset(x, 5).Value = RS.Fields("partner").Value
.Offset(x, 6).Value = RS.Fields("description").Value
End If
End With
RS.MoveNext
Next
RS.Close
DB.Close
XLApp.Application.Visible = True
GoTo theend
I am trying to copy individual records from a recordset (table) into rows of an excel spreadsheet. But the records refuse to copy into the s/sheet.
Does anybody have any ideas why?
Any help is much appreciated (you are doing a great job here...thanks)
Dion