D
DDawson
Dear Access Gurus
I have an inspections database and I want to print out the survey results
for the selected sites in a report.
I have no problems populating the fields in the userform and selecting the
fields. The problem occurs when I try to print. The report get the selected
records from a query and I am trying to output the selected records from the
form to the query.
Here is the printbutton on the userform
Private Sub btnPrintReport_Click()
Dim vItm As Variant
Dim strCriteria As String
Dim intView As Integer
Dim intWindowMode As Integer
strCriteria = "[Site] In ("
For Each vItm In Me!mslbxSites.ItemsSelected
strCriteria = strCriteria & "'" & _
Trim(Me!mslbxSites.ItemData(vItm)) & "', "
Next vItm
strCriteria = Left(strCriteria, Len(strCriteria) - 2) & ")"
'For CheckBox named ckPreview, where Default=True
If ckPreview Then
intView = acPreview
intWindowMode = acDialog
Else
intView = acViewNormal
intWindowMode = acWindowNormal
End If
DoCmd.OpenReport "rptSiteSurvey", intView, strCriteria, intWindowMode
End Sub
It appears to work fine, except, when it tries to open the report
rptSiteSurvey. A popup appears with the comment
"frmSiteSurveyRpt!mslbxSites". I have examined this and believe it comes down
to one line in the query. Here is the query:
SELECT SurveyData.[Date of Survey], SurveyData.Site, SurveyData.Element,
SurveyData.Condition, SurveyData.PriorityRef, SurveyData.[Revenue Cost],
SurveyData.[Revenue Comments], SurveyData.[Remaining Life],
SurveyData.[Capital Cost], SurveyData.[Capital Comments]
FROM SurveyData
WHERE (((SurveyData.Site)=[frmSiteSurveyRpt]![mslbxSites]))
ORDER BY SurveyData.[Date of Survey], SurveyData.Site, SurveyData.Element;
I believe it comes down to the WHERE (((SurveyData.Site)=... line, because,
when I changed it to ...[frmSiteSurveyRpt].[mslbxSites])) the popup comment
changed to this also. I'm sure this is something quite simple to fix, but I
can't put my finger on it.
DDawson
I have an inspections database and I want to print out the survey results
for the selected sites in a report.
I have no problems populating the fields in the userform and selecting the
fields. The problem occurs when I try to print. The report get the selected
records from a query and I am trying to output the selected records from the
form to the query.
Here is the printbutton on the userform
Private Sub btnPrintReport_Click()
Dim vItm As Variant
Dim strCriteria As String
Dim intView As Integer
Dim intWindowMode As Integer
strCriteria = "[Site] In ("
For Each vItm In Me!mslbxSites.ItemsSelected
strCriteria = strCriteria & "'" & _
Trim(Me!mslbxSites.ItemData(vItm)) & "', "
Next vItm
strCriteria = Left(strCriteria, Len(strCriteria) - 2) & ")"
'For CheckBox named ckPreview, where Default=True
If ckPreview Then
intView = acPreview
intWindowMode = acDialog
Else
intView = acViewNormal
intWindowMode = acWindowNormal
End If
DoCmd.OpenReport "rptSiteSurvey", intView, strCriteria, intWindowMode
End Sub
It appears to work fine, except, when it tries to open the report
rptSiteSurvey. A popup appears with the comment
"frmSiteSurveyRpt!mslbxSites". I have examined this and believe it comes down
to one line in the query. Here is the query:
SELECT SurveyData.[Date of Survey], SurveyData.Site, SurveyData.Element,
SurveyData.Condition, SurveyData.PriorityRef, SurveyData.[Revenue Cost],
SurveyData.[Revenue Comments], SurveyData.[Remaining Life],
SurveyData.[Capital Cost], SurveyData.[Capital Comments]
FROM SurveyData
WHERE (((SurveyData.Site)=[frmSiteSurveyRpt]![mslbxSites]))
ORDER BY SurveyData.[Date of Survey], SurveyData.Site, SurveyData.Element;
I believe it comes down to the WHERE (((SurveyData.Site)=... line, because,
when I changed it to ...[frmSiteSurveyRpt].[mslbxSites])) the popup comment
changed to this also. I'm sure this is something quite simple to fix, but I
can't put my finger on it.
DDawson