Hi Forum, 2000 converted to 2010
After installing 2010 when I click for a single record report to run All 7,000 odd records have a report produced.
Any Ideas what may be causing the "strWhere" to not restrict the records printed??
This code is the On Click event to print a Report
And here is part of the Function the above code calls
After installing 2010 when I click for a single record report to run All 7,000 odd records have a report produced.
Any Ideas what may be causing the "strWhere" to not restrict the records printed??
This code is the On Click event to print a Report
Code:
Private Sub CmdFrmSingleLoanStatement_Click()
On Error GoTo Err_CmdFrmSingleLoanStatement_Click
Dim LoanID As Integer 'Variable to hold Loan ID
LoanID = Me.txtLDPK 'put value from form control to variable
LoanID = CStr(LoanID) 'convert variable to string
LoanStatementSingle (LoanID) 'call function to Generate Statement
Exit_CmdFrmSingleLoanStatement_Click:
Exit Sub
Err_CmdFrmSingleLoanStatement_Click:
MsgBox Err.Description
Resume Exit_CmdFrmSingleLoanStatement_Click
End Sub
And here is part of the Function the above code calls
Code:
Public Function LoanStatementSingle(LoanRef As String, Optional DoNotEmail As String) 'general function to print a single Loan Statement with Option to email or not
Dim strWhere As String
Dim FullName As String 'Variable to hold Full Name
Dim FirstName As String 'Variable to hold first Name
Dim strSQL As String 'Variable to hold SQL Statement
Dim Response As String 'Variable to hold response to Message Box Questions
Dim TeamMember As String 'variable to hold Team Member Full Name
Dim dbs As DAO.Database, rst As DAO.Recordset
Set dbs = CurrentDb()
TeamMember = TeamMemberName() 'put result of function as Team member Full Name
'SQL to Collect Club Member Full Name
strSQL = "SELECT TBLLOAN.LDPK, [ADFirstname] & "" "" & [ADSurname] AS FullName " & _
"FROM TBLACCDET INNER JOIN TBLLOAN ON TBLACCDET.ADPK = TBLLOAN.ADPK " & _
"WHERE (((TBLLOAN.LDPK)=" & LoanRef & "));"
'Open Recordset
Set rst = dbs.OpenRecordset(strSQL)
FullName = rst!FullName 'Put Result of sql as Variable FullName
strWhere = "LDPK = " & LoanRef
DoCmd.OpenReport "RptStatementNewStyle", acViewPreview, , strWhere
' Stephen Lebans Save to .PDF Code
Dim blRet As Boolean
' Call our convert function
' Please note the last param signals whether to perform
' font embedding or not. I have turned font embedding ON for this example.
blRet = ConvertReportToPDF("RptStatementNewStyle", vbNullString, _
"W:\Attachments\" & FullName & " Loan " & LoanRef & " Statement " & TeamMember & ".pdf", False, False, 150, "", "", 0, 0, 0)
' To modify the above call to force the File Save Dialog to select the name and path
' for the saved PDF file simply change the ShowSaveFileDialog param to TRUE.