Hello All,
I'm trying to export a Query from a Access 2000 database to a Excel spreadsheet. The user will enter two dates that he/she would like to the data between. EX. All data between 10-Aug-01 To 20-Aug-01. I'm not really sure how to go about doing this, I'm relatively new to VBA.
Here is what I have started
'open database
Dim db As DAO.Database
Dim qryRDT As QueryDef
Set db = CurrentDb
'set the dates the user entered into variables
txtSDate.SetFocus
SDate = txtSDate.Text
txtEDate.SetFocus
EDate = txtEDate.Text
' Generate report based on what option user has selected
DoCmd.OpenQuery "RDT", acViewDesign
'Include all these records in the report
Set qryRDT = db.QueryDefs("RDT"
qryRDT.SQL = "SELECT [Project ID Master].[Project ID]," _
& "[Project ID Master].[Project Health]," _
& "[Project ID Master].[Project/Service/Description]," _
& "[Project ID Master].[Client BC Owner]," _
& "[Project ID Master].[Project Start Date]," _
& "[Project ID Master].[Project Owner]," _
& "[Project ID Master].[Project Manager]," _
& "[Project ID Master].[Billed To Date]," _
& "FROM [Project ID Master]" _
& "WHERE (([Project ID Master].[Project Start Date]) AND (([Project ID Master].[Project Close Date]) Between " & Chr(35) & SDate & Chr(35) & " AND " & Chr(35) & EDate & Chr(35) & ")" _
& "ORDER BY [Project ID Master].[Project Start Date];"
DoCmd.OpenQuery "RDT", acViewPreview
DoCmd.RunMacro "OutputWeeklyReport"
MsgBox "Emport Complete", vbInformation, "Export Status"
' Close db
db.Close
Set db = Nothing
Any thoughts or advice would be great!
Thanks
Dutt
I'm trying to export a Query from a Access 2000 database to a Excel spreadsheet. The user will enter two dates that he/she would like to the data between. EX. All data between 10-Aug-01 To 20-Aug-01. I'm not really sure how to go about doing this, I'm relatively new to VBA.
Here is what I have started
'open database
Dim db As DAO.Database
Dim qryRDT As QueryDef
Set db = CurrentDb
'set the dates the user entered into variables
txtSDate.SetFocus
SDate = txtSDate.Text
txtEDate.SetFocus
EDate = txtEDate.Text
' Generate report based on what option user has selected
DoCmd.OpenQuery "RDT", acViewDesign
'Include all these records in the report
Set qryRDT = db.QueryDefs("RDT"
qryRDT.SQL = "SELECT [Project ID Master].[Project ID]," _
& "[Project ID Master].[Project Health]," _
& "[Project ID Master].[Project/Service/Description]," _
& "[Project ID Master].[Client BC Owner]," _
& "[Project ID Master].[Project Start Date]," _
& "[Project ID Master].[Project Owner]," _
& "[Project ID Master].[Project Manager]," _
& "[Project ID Master].[Billed To Date]," _
& "FROM [Project ID Master]" _
& "WHERE (([Project ID Master].[Project Start Date]) AND (([Project ID Master].[Project Close Date]) Between " & Chr(35) & SDate & Chr(35) & " AND " & Chr(35) & EDate & Chr(35) & ")" _
& "ORDER BY [Project ID Master].[Project Start Date];"
DoCmd.OpenQuery "RDT", acViewPreview
DoCmd.RunMacro "OutputWeeklyReport"
MsgBox "Emport Complete", vbInformation, "Export Status"
' Close db
db.Close
Set db = Nothing
Any thoughts or advice would be great!
Thanks
Dutt