D
DDawson
I have an inspections database and one of the forms has stopped working. Can
you please help me to fix it.
The form, when it works, allows the user to select multiple sites from a
list and when the print button is pressed, prints the survey results for the
selected sites. The form also has a tickbox, set to yes by default, which
allows the user to preview the report when the print button is pressed.
I currently get an error highlighting Trim... (line 10) the error message
states "compile error can't find project or library". I think this may be due
to me working on it at home, because when I try it at my work's computer I
get an error at DoCmd (the second last line) line, where it highlights
strCriteria.
Here is the code behind the print button:
btw. mslbxSites refers to the fom's multi-select listbox containing a list
of all the sites.
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
I hope this is enough for you more experienced guys to identify the problem,
please let me know if you need any more info.
Kind regards
Dylan Dawson
you please help me to fix it.
The form, when it works, allows the user to select multiple sites from a
list and when the print button is pressed, prints the survey results for the
selected sites. The form also has a tickbox, set to yes by default, which
allows the user to preview the report when the print button is pressed.
I currently get an error highlighting Trim... (line 10) the error message
states "compile error can't find project or library". I think this may be due
to me working on it at home, because when I try it at my work's computer I
get an error at DoCmd (the second last line) line, where it highlights
strCriteria.
Here is the code behind the print button:
btw. mslbxSites refers to the fom's multi-select listbox containing a list
of all the sites.
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
I hope this is enough for you more experienced guys to identify the problem,
please let me know if you need any more info.
Kind regards
Dylan Dawson