Hi All
The following code displays the total number of records and total records signed off for a particular date. It works fine. But now I want to display the details of records that are not signed off so that the client may know which records are those and can come to know why they are not signed off. I want to display everything all together in same excelsheet.
I know we can write the following query:
But can we export the data all together in the same excelsheet Like the counting at the top and then after that records which are not signed off.
Thanks
The following code displays the total number of records and total records signed off for a particular date. It works fine. But now I want to display the details of records that are not signed off so that the client may know which records are those and can come to know why they are not signed off. I want to display everything all together in same excelsheet.
Code:
Dim strsql As String
strsql = "Select count(*) as [Total Recorded Items],count(Signoff) as [Total Items Signed Off] from completed_table where datevalue(Date1)=#" & Format(Date, "mm/dd/yyyy") & "#"
If DCount("Name", "MSysobjects", "Name='qrytemp' and type=5") > 0 Then
DoCmd.DeleteObject acQuery, "qrytemp"
End If
Set qdf = CurrentDb.CreateQueryDef("qrytemp", strsql)
Dim objXls As Excel.Application
Dim objWrkBk As Excel.Workbook
Dim xprtFile As String
xprtFile = "J:\Report.xls"
DoCmd.OutputTo acOutputQuery, "qrytemp", acFormatXLS, xprtFile, False
Set objXls = New Excel.Application
objXls.Visible = False
Const xlLandscape = 2
Set objWrkBk = objXls.Workbooks.Open(xprtFile)
objWrkBk.Sheets("qrytemp").Select
Dim J As Integer
J = objWrkBk.ActiveSheet.UsedRange.Rows.Count
With objWrkBk.Sheets("qrytemp")
.Application.Rows("1:1").Select
.Application.Selection.Font.Bold = True
'.Quit
End With
With objWrkBk.Sheets("qrytemp").PageSetup
.LeftHeader = "Requested Date: " & Format(Date, "dd/mm/yyyy")
.CenterHeader = "&""Arial,Bold""&14" & "Daily Report For Total Recorded Items Signed Off"
.Orientation = xlLandscape
End With
objWrkBk.Sheets("qrytemp").Columns.AutoFit
objWrkBk.PrintOut
objWrkBk.Close savechanges:=False
MsgBox "The Report has been printed off"
Set objWrkBk = Nothing
objXls.Quit
Set objXls = Nothing
Set qdf = Nothing
I know we can write the following query:
Code:
strsql="Select * from tblmain where Signed=null"
But can we export the data all together in the same excelsheet Like the counting at the top and then after that records which are not signed off.
Thanks