B
Billy B
I have an unbound form with a listbox with the following settings:
Row Source Type = Table/Query
Row Source = SELECT DISTINCT Code FROM [TEST Master] WHERE Code>=0 ORDER BY
Code;
Bound column 1
Multiselect is Simple
The field value for code in the table is number.
The user selects the codes they want from the list box and then I want to
open the report rptTesting displaying only the data for the code numbers
selected in the list box.
Private Sub cmdListboxOfQueries_Click()
Dim intCount As Integer
Dim varItem As
Dim intLength As Integer 'To determine length of final string
'then delete the trailing " OR "
Dim strTblField As String
Dim strOR As String
Dim strFinalString As Variant
strTblField = "
Row Source Type = Table/Query
Row Source = SELECT DISTINCT Code FROM [TEST Master] WHERE Code>=0 ORDER BY
Code;
Bound column 1
Multiselect is Simple
The field value for code in the table is number.
The user selects the codes they want from the list box and then I want to
open the report rptTesting displaying only the data for the code numbers
selected in the list box.
Private Sub cmdListboxOfQueries_Click()
Dim intCount As Integer
Dim varItem As
Dim intLength As Integer 'To determine length of final string
'then delete the trailing " OR "
Dim strTblField As String
Dim strOR As String
Dim strFinalString As Variant
strTblField = "
Code:
= """
strConcChar = " & "
strOR = "' Or '"
intCount = 0
'Using the ItemsSelected Property
With lstCodeNumbers
If .MultiSelect = 0 Then
txtSelected = .Value
Else
For Each varItem In .ItemsSelected
strList = strTblField & " " & .Column(0, varItem) & strOR
txtSelected = txtSelected & strList
strList = ""
intCount = intCount + 1
Next varItem
End If
intLength = Len(txtSelected) 'length of string
txtSelected = Left(txtSelected, intLength - 4) 'delete the right 4
characters
'**************
'For testing show string in the textbox of the form
Me.txtFinalLblString.SetFocus
Me.txtFinalLblString.Text = txtSelected
'**************
strFinalString = txtSelected
End With
DoCmd.OpenReport "rptTesting", acViewPreview, , , , strFinalString
‘Open Event code for report
‘Get syntax error
Private Sub Report_Open(Cancel As Integer)
'Me.OpenArgs
MsgBox Me.OpenArgs
'DoCmd.OpenForm "frmSortCodes", , , , , acDialog
Me.Filter = OpenArgs
'Me.FilterOn
End Sub
I get a syntax error. I have been trying to get the opening args to work now
for three days. Any help would be greatly appreciated.
Thank you.