lucky245
08-28-2006, 11:37 PM
I am creating a report using Sql in an Access module in which I pass in a Request no and a title (see below):banghead:
Sub RunGlobalReport(intPrintno As String, strTitle As String)
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = CurrentDb
Set qdf = db.QueryDefs("qryStaffListQuery")
strSQL = CreateEWTDSQL(intPrintno)
qdf.SQL = strSQL
qdf.name = strTitle
DoCmd.OpenQuery strTitle, acViewPreview
qdf.name = "qryStaffListQuery"
End Sub
Function CreateEWTDSQL(intPrintno As Integer) As String
Dim strSQL As String
'Set row source for list box
strSQL = "SELECT strSurname,strInitials, strStaffNo,strGrade,"
If intPrintno = 1 Then strSQL = strSQL & " AvgHoursNorm1, AvgHoursUnsoc1 "
If intPrintno = 2 Then strSQL = strSQL & " AvgHoursNorm2, AvgHoursUnsoc2 "
If intPrintno = 3 Then strSQL = strSQL & " AvgHoursNorm3, AvgHoursUnsoc3 "
strSQL = strSQL & "FROM qryEWTD "
CreateEWTDSQL = strSQL
End Function
This works perfectly except it needs to be in landscape and not portrait, I would also like to reduce the margins from their preset sizes if possible. I do not need this format all of the time hence wishing to change it as required.
Thankyou for any help:bow:
Sub RunGlobalReport(intPrintno As String, strTitle As String)
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strSQL As String
Set db = CurrentDb
Set qdf = db.QueryDefs("qryStaffListQuery")
strSQL = CreateEWTDSQL(intPrintno)
qdf.SQL = strSQL
qdf.name = strTitle
DoCmd.OpenQuery strTitle, acViewPreview
qdf.name = "qryStaffListQuery"
End Sub
Function CreateEWTDSQL(intPrintno As Integer) As String
Dim strSQL As String
'Set row source for list box
strSQL = "SELECT strSurname,strInitials, strStaffNo,strGrade,"
If intPrintno = 1 Then strSQL = strSQL & " AvgHoursNorm1, AvgHoursUnsoc1 "
If intPrintno = 2 Then strSQL = strSQL & " AvgHoursNorm2, AvgHoursUnsoc2 "
If intPrintno = 3 Then strSQL = strSQL & " AvgHoursNorm3, AvgHoursUnsoc3 "
strSQL = strSQL & "FROM qryEWTD "
CreateEWTDSQL = strSQL
End Function
This works perfectly except it needs to be in landscape and not portrait, I would also like to reduce the margins from their preset sizes if possible. I do not need this format all of the time hence wishing to change it as required.
Thankyou for any help:bow: