Report breaks on dynamic recordsource, but returns correct data

J

jhanby1

I'm working with a MS Access FE and a SQL Server 2000 BE. I have a
report in MS Access 2003 called rptMeetingsScheduled. After assigning a
variable to the appropriate date I want to display, I open the report
and dynamically assign the report's recordsource in the OnOpen event.
Below is the code that does this:

Dim strSQL As String

If IsNull(strRP1) Or strRP1 = "" Then

strSQL = "SELECT [FirstName] & ' ' & [LastName] AS Name,
tblCaseManager.[Case Manager Initial], tblCases.CaseNumber,
IIf(IsNull([Case Manager Name]),'No Case Mgr. Assigned',[Case Manager
Name]) AS [Case Mgr], tblCases.[Case Name], tblCases.[Case Status],
tblCases.[Entered Date] AS [Date Opened], Nz([Location],[CaseLocation])
AS [Meeting Location], qselLatestMeetingForReport.Date,
qselLatestMeetingForReport.Time, tblCases.[Case Closed Date],
qselLatestMeetingForReport.NumberofParties,
qselLatestMeetingForReport.[Date Pulled for Confirmation],
qselLatestMeetingForReport.[Date of 10-day Letter] " & _
"FROM ((tblCaseManager RIGHT JOIN tblCases ON
tblCaseManager.ID = tblCases.[Case Manager ID]) INNER JOIN
qselLatestMeetingForReport ON tblCases.tblCasesID =
qselLatestMeetingForReport.tblCasesID) INNER JOIN tblLawyers ON
qselLatestMeetingForReport.LawyerID = tblLawyers.LawyerID " & _
"WHERE (((qselLatestMeetingForReport.Date) Is Not
Null) And ((qselLatestMeetingForReport.[Date Meeting Canceled]) Is
Null)) " & _
" ORDER BY qselLatestMeetingForReport.Date,
qselLatestMeetingForReport.Time;"

Else

strSQL = "SELECT [FirstName] & ' ' & [LastName] AS Name,
tblCaseManager.[Case Manager Initial], tblCases.CaseNumber,
IIf(IsNull([Case Manager Name]),'No Case Mgr. Assigned',[Case Manager
Name]) AS [Case Mgr], tblCases.[Case Name], tblCases.[Case Status],
tblCases.[Entered Date] AS [Date Opened], Nz([Location],[CaseLocation])
AS [Meeting Location], qselLatestMeetingForReport.Date,
qselLatestMeetingForReport.Time, tblCases.[Case Closed Date],
qselLatestMeetingForReport.NumberofParties,
qselLatestMeetingForReport.[Date Pulled for Confirmation],
qselLatestMeetingForReport.[Date of 10-day Letter] " & _
"FROM ((tblCaseManager RIGHT JOIN tblCases ON
tblCaseManager.ID = tblCases.[Case Manager ID]) INNER JOIN
qselLatestMeetingForReport ON tblCases.tblCasesID =
qselLatestMeetingForReport.tblCasesID) INNER JOIN tblLawyers ON
qselLatestMeetingForReport.LawyerID = tblLawyers.LawyerID " & _
"WHERE (((qselLatestMeetingForReport.Date) Is Not
Null) And ((qselLatestMeetingForReport.[Date Meeting Canceled]) Is
Null)) AND " & strRP1 & _
" ORDER BY qselLatestMeetingForReport.Date,
qselLatestMeetingForReport.Time;"

End If
Me.RecordSource = strSQL


The code looks cleaner in my VBA editor :)

The problem is when I open the report in my system, my users have the
VBA window pop up w/ the "Me.RecordSource = strSQL" highlighted. I am
not sure why the code is breaking here. No errors are thrown/logged.
And if I step through the code, everything opens up just fine. The data
is accurate and all other code executes perfectly.

Any ideas???
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top