B
Bob Wickham
Hi,
I am trying to get the OpenArgs on my report to display Yes or No instead
of -1 or 0.
I have an unbound listbox on a form with its Row Source property set to
SELECT DISTINCT tblCommission.Debtored FROM tblCommission;
The debtored field is a Yes/No field in the table tblCommission and when it
appears on the form it reads Yes or No.
I'm using a multi-select listbox instead of check boxes as there are 3
possible choices, Yes, No or Both
The code that runs from the OnClick event of a button is (in part) which is
borrowed mostly from Allen Browne.
With Me.lstDebtored
For Each varItem In .ItemsSelected
If Not IsNull(varItem) Then
'Build up the filter from the bound column
strWhere5 = strWhere5 & strDelim5 & .ItemData(varItem) &
strDelim5 & ","
'Build up the description from the text in the visible
column.
strDescrip5 = strDescrip5 & """" & .Column(0, varItem) &
""", "
End If
Next
End With
'Remove trailing comma. Add field name, IN operator, and brackets.
lngLen = Len(strWhere5) - 1
If lngLen > 0 Then
strWhere5 = "[Debtored] IN (" & Left$(strWhere5, lngLen) & ")"
lngLen = Len(strDescrip5) - 2
If lngLen > 0 Then
strDescrip5 = "DEBTORED: " & Left$(strDescrip5, lngLen)
End If
End If
'and then at the end
strWhere = "(" & strWhere1 & ") AND (" & strWhere2 & ") AND (" & strWhere3 &
") AND (" & strWhere4 & ") AND (" & strWhere5 & ")"
strDescrip = "(" & strDescrip1 & ") AND (" & strDescrip2 & ") AND (" &
strDescrip3 & ") AND (" & strDescrip4 & ") AND (" & strDescrip5 & ")"
DoCmd.OpenReport strDoc, acViewPreview, WhereCondition:=strWhere,
OpenArgs:=strDescrip
In the header of my report I have =Report.OpenArgs.
If "No" is selected on the form, then strDescrip5 is displayed in OpenArgs
on the report as "0"
If "Yes" is selected on the form, then strDescrip5 is displayed in OpenArgs
on the report as "-1"
I need to be able to display it as "No" or "Yes".
I have tried all sorts of ways such as
If strDescrip5 = "-1" Then
strDescrip5 = "Yes"
End If
If strDescrip5 = "0" Then
strDescrip5 = "No"
End If
but it doesn't make any difference.
Any ideas greatly appreciated.
Bob
I am trying to get the OpenArgs on my report to display Yes or No instead
of -1 or 0.
I have an unbound listbox on a form with its Row Source property set to
SELECT DISTINCT tblCommission.Debtored FROM tblCommission;
The debtored field is a Yes/No field in the table tblCommission and when it
appears on the form it reads Yes or No.
I'm using a multi-select listbox instead of check boxes as there are 3
possible choices, Yes, No or Both
The code that runs from the OnClick event of a button is (in part) which is
borrowed mostly from Allen Browne.
With Me.lstDebtored
For Each varItem In .ItemsSelected
If Not IsNull(varItem) Then
'Build up the filter from the bound column
strWhere5 = strWhere5 & strDelim5 & .ItemData(varItem) &
strDelim5 & ","
'Build up the description from the text in the visible
column.
strDescrip5 = strDescrip5 & """" & .Column(0, varItem) &
""", "
End If
Next
End With
'Remove trailing comma. Add field name, IN operator, and brackets.
lngLen = Len(strWhere5) - 1
If lngLen > 0 Then
strWhere5 = "[Debtored] IN (" & Left$(strWhere5, lngLen) & ")"
lngLen = Len(strDescrip5) - 2
If lngLen > 0 Then
strDescrip5 = "DEBTORED: " & Left$(strDescrip5, lngLen)
End If
End If
'and then at the end
strWhere = "(" & strWhere1 & ") AND (" & strWhere2 & ") AND (" & strWhere3 &
") AND (" & strWhere4 & ") AND (" & strWhere5 & ")"
strDescrip = "(" & strDescrip1 & ") AND (" & strDescrip2 & ") AND (" &
strDescrip3 & ") AND (" & strDescrip4 & ") AND (" & strDescrip5 & ")"
DoCmd.OpenReport strDoc, acViewPreview, WhereCondition:=strWhere,
OpenArgs:=strDescrip
In the header of my report I have =Report.OpenArgs.
If "No" is selected on the form, then strDescrip5 is displayed in OpenArgs
on the report as "0"
If "Yes" is selected on the form, then strDescrip5 is displayed in OpenArgs
on the report as "-1"
I need to be able to display it as "No" or "Yes".
I have tried all sorts of ways such as
If strDescrip5 = "-1" Then
strDescrip5 = "Yes"
End If
If strDescrip5 = "0" Then
strDescrip5 = "No"
End If
but it doesn't make any difference.
Any ideas greatly appreciated.
Bob