Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exporting recordset to excel file

Status
Not open for further replies.

dazbc

Technical User
Jun 28, 2006
14
0
0
IE
Does anyone know how to export the results of a recordset into an excel file, i know it may sound abit vague and alot of work but i honestly dont even know where to start the exporting...

heres the recordset code that originally fills a textbox with the recordset result...

Private Sub EnterDate_Click()

Dim strEuro As String
Dim VATQuerySet As DAO.Recordset
Dim SQL As String

strEuro = "€"
strSpace = " "
strMonth = Me.MonthCombo
intYear = Me.YearCombo
strEmployee = Me.EmployeeCombo

SQL = "SELECT BillingMonths.[Total Excluding VAT] " & _
"FROM SimsUpdate " & _
"INNER JOIN BillingMonths " & _
"ON SimsUpdate.GSM = BillingMonths.GSM " & _
"WHERE (BillingMonths.[Month] = '" & strMonth & "') AND " & _
"(BillingMonths.[Year] = " & intYear & ") AND " & _
"(SimsUpdate.[Employee Name] = '" & strEmployee & "')"

Set VATQuerySet = CurrentDb.OpenRecordset(SQL)

Me.TotalExcludingVATTextbox.SetFocus

If (Me.EnterDate.Enabled = True) Then

If VATQuerySet.EOF Or VATQuerySet.BOF Then
MsgBox "There is no available bill for " & vbCr & vbCr & strMonth & strSpace & intYear, vbOKOnly + vbInformation, "Date Error Occured:"
Me.TotalExcludingVATTextbox.Text = blankVar

Else
VATQuerySet.MoveFirst
Me.TotalExcludingVATTextbox.Enabled = True
Me.TotalExcludingVATTextbox.Text = strEuro + VATQuerySet.Fields(0)
End If

Me.EnterDate.SetFocus

End If

End Sub
 

You could use the CopyFromRecordset method of the Range object of an excel instance you have already created and have defined the woorkbook in which you select the workseet to paste.
 
Could you simplify that please...?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top