S
Slez via AccessMonster.com
I have a multi select list box which allows me to view and print reports
based on selecting one or more desired project bids and then select a
specific report to run based on an option button selection. Works great...
but...now I'd like to be able to open a FORM via command button
"cmdCopyBidInfo". What do I alter in the following code for the new command
button to function based on what is selected in the multi select list box?
I've tried a few things, but can't get it to work. Any help is appreciated!!!
Here is that code:
Private Sub cmdViewBidInfo_Click()
Dim ctlSource As Control
Dim strItems As String
Dim intProjectID As Integer
Dim intCurrentRow As Integer, SelectedRows As Integer
Set ctlSource = Me.lstBidSelectBOM
intProjectID = Forms!frmMainScreen!cboProjectMatl
'Debug.Print intProjectID
For intCurrentRow = 0 To ctlSource.ListCount - 1
If ctlSource.Selected(intCurrentRow) Then
If SelectedRows >= 1 Then
strItems = strItems & " or BidNumber = "
End If
strItems = strItems & ctlSource.Column(0, intCurrentRow)
SelectedRows = SelectedRows + 1
End If
Next intCurrentRow
strItems = strItems
If Len(strItems) = 0 Then
MsgBox "You did not select anything from the list. " _
, vbExclamation, "Nothing selected!"
Exit Sub
End If
strCriteria = "BidNumber = "
strCriteria = strCriteria & strItems
'Debug.Print strCriteria
strCriteria = "(" & strCriteria & ")" & " and ProjectID = " &
intProjectID
'Debug.Print strCriteria
Select Case Frame36
Case 1
DoCmd.OpenReport "rptBOMBidItem", acViewPreview, , strCriteria
Case 2
DoCmd.OpenReport "rptBOMBidMatl", acViewPreview, , strCriteria
End Select
End Sub
based on selecting one or more desired project bids and then select a
specific report to run based on an option button selection. Works great...
but...now I'd like to be able to open a FORM via command button
"cmdCopyBidInfo". What do I alter in the following code for the new command
button to function based on what is selected in the multi select list box?
I've tried a few things, but can't get it to work. Any help is appreciated!!!
Here is that code:
Private Sub cmdViewBidInfo_Click()
Dim ctlSource As Control
Dim strItems As String
Dim intProjectID As Integer
Dim intCurrentRow As Integer, SelectedRows As Integer
Set ctlSource = Me.lstBidSelectBOM
intProjectID = Forms!frmMainScreen!cboProjectMatl
'Debug.Print intProjectID
For intCurrentRow = 0 To ctlSource.ListCount - 1
If ctlSource.Selected(intCurrentRow) Then
If SelectedRows >= 1 Then
strItems = strItems & " or BidNumber = "
End If
strItems = strItems & ctlSource.Column(0, intCurrentRow)
SelectedRows = SelectedRows + 1
End If
Next intCurrentRow
strItems = strItems
If Len(strItems) = 0 Then
MsgBox "You did not select anything from the list. " _
, vbExclamation, "Nothing selected!"
Exit Sub
End If
strCriteria = "BidNumber = "
strCriteria = strCriteria & strItems
'Debug.Print strCriteria
strCriteria = "(" & strCriteria & ")" & " and ProjectID = " &
intProjectID
'Debug.Print strCriteria
Select Case Frame36
Case 1
DoCmd.OpenReport "rptBOMBidItem", acViewPreview, , strCriteria
Case 2
DoCmd.OpenReport "rptBOMBidMatl", acViewPreview, , strCriteria
End Select
End Sub