Public Sub OroExpenses()
Dim Report As CRAXDRT.Report
Dim str As String
Set Report = New crysExpenses
str = "{TblPora.Thedate} =#" & Format$(mainfrm.Mydate) & "# And {TblPora.Typep}='" & RP & "'"
Report.RecordSelectionFormula = str
Report.ReadRecords
Call Report.SelectPrinter(Report.DriverName, Report.PrinterName, Report.PortName)
Report.H1.SetText Header
cr.ReportSource = Report
cr.ViewReport
cr.EnableExportButton = True
cr.EnablePopupMenu = True
cr.Zoom 94
Set Report = Nothing
End Sub
Public Sub SetReportDatabase(ByRef RPT As CRAXDRT.Report)
Dim iErr As Integer
Dim t As Integer
Dim srT As Integer
10 iErr = 0
20 On Error GoTo PROC_ERR
30 For t = 1 To RPT.Database.Tables.count
' RPT.Database.Tables(t).ConnectBufferString = "DSN=" & gDBNAME & ";;UseDSNProperties=0"
' YOUR CONNECTION FROM ABOVE
RPT.Database.Tables(t).ConnectBufferString = "DSN =" & SystemDSN & "; UID =" & DBUser & " ; PWD =" & DBUserPwd & " "
50 Next
SetSubReportDatabase RPT
PROC_EXIT:
60 Exit Sub
PROC_ERR:
70 If InStr(1, UCase(ERR.Description), "READ-ONLY", vbTextCompare) > 0 Then Exit Sub
80 If iErr > 3 Then
90 ' YOUR ERROR TRAP HERE
100 Resume PROC_EXIT
110 Else
120 iErr = iErr + 1
130 Resume
140 End If
End Sub
Public Sub IliganExpenses()
Call SetReportDatabase(Report)
Dim str As String
Set Report = New crysExpensesIligan
str = "{TblPora.Thedate} =#" & Format$(mainfrm.Mydate) & "# And {TblPora.Typep}='" & RP & "'"
Report.RecordSelectionFormula = str
Report.ReadRecords
Call Report.SelectPrinter(Report.DriverName, Report.PrinterName, Report.PortName)
Report.H1.SetText Header(0)
Report.H2.SetText Header(1)
Report.H3.SetText "Date: " & Format$(mainfrm.Mydate.Value, "MMMM DD YYYY")
Report.H4.SetText Header(2)
cr.ReportSource = Report
cr.ViewReport
cr.EnableExportButton = True
cr.EnablePopupMenu = True
cr.Zoom 94
Set Report = Nothing
End Sub
Public Sub SetReportDatabase(ByRef RPT As CRAXDRT.Report)
Dim iErr As Integer
Dim t As Integer
Dim srT As Integer
10 iErr = 0
20 On Error GoTo PROC_ERR
30 For t = 1 To RPT.Database.Tables.Count
'RPT.Database.Tables(t).ConnectBufferString = "DSN=" & gDBNAME & ";;UseDSNProperties=0"
' YOUR CONNECTION FROM ABOVE
RPT.Database.Tables(t).ConnectBufferString = "DSN =" & "Sample" & "; UID =" & "Winpos" & " ; PWD =" & "sa" & " "
50 Next
SetSubReportDatabase RPT
PROC_EXIT:
60 Exit Sub
PROC_ERR:
70 If InStr(1, UCase(Err.Description), "READ-ONLY", vbTextCompare) > 0 Then Exit Sub
80 If iErr > 3 Then
90 ' YOUR ERROR TRAP HERE
100 Resume PROC_EXIT
110 Else
120 iErr = iErr + 1
130 Resume
140 End If
End Sub
Hi Haroon!
Sorry but can you correct my code below base of the code you had shared to me..
My Database is DB001 I'm using mssql7
My dbuser is OroSales
pwd = sa
I've got an error when I execute the code..
Thanks!
Open in new window