Blackwidow
Registered User.
- Local time
- Today, 02:31
- Joined
- Apr 30, 2003
- Messages
- 149
This is my first time doing this so bear with me, i have tried a couple examples in the database but keep getting stuck at the same point (my VB is not the best)
I want to run student reports for students selected through the list box, on highlighting them it puts their Admission Number into a field on the form called txtCriteria1 and then I click run report...
What should happen is that it will filter and run the report for each child selected... what it does is nothing
Private Sub Command4_Click()
'Preview Report
On Error GoTo Command4_Click_Error
If IsNull("Me.txtCriteria1") Or Me.txtCriteria1 = "" Then
Exit Sub
Else
DoCmd.OpenReport "rptMultipleStudentDataReport", acPreview
End If
On Error GoTo 0
Exit Sub
Command4_Click_Error:
If Err.Number = 2501 Then
Exit Sub
Else
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Command4_Click of VBA Document Form_Multi-Select Listbox Example"
End If
End Sub
Private Sub List2_AfterUpdate()
Dim Criteria As String
Dim ctl As Control
Dim Itm As Variant
' Build a list of the selections.
Set ctl = Me.List2
For Each Itm In ctl.ItemsSelected
If Len(Criteria) = 0 Then
Criteria = ctl.ItemData(Itm)
Else
Criteria = Criteria & "," & ctl.ItemData(Itm)
End If
Next Itm
Me.txtCriteria1 = Criteria
End Sub
this is the code I have been using... do I need to alter the query the report is based on somehow?
I want to run student reports for students selected through the list box, on highlighting them it puts their Admission Number into a field on the form called txtCriteria1 and then I click run report...
What should happen is that it will filter and run the report for each child selected... what it does is nothing
Private Sub Command4_Click()
'Preview Report
On Error GoTo Command4_Click_Error
If IsNull("Me.txtCriteria1") Or Me.txtCriteria1 = "" Then
Exit Sub
Else
DoCmd.OpenReport "rptMultipleStudentDataReport", acPreview
End If
On Error GoTo 0
Exit Sub
Command4_Click_Error:
If Err.Number = 2501 Then
Exit Sub
Else
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Command4_Click of VBA Document Form_Multi-Select Listbox Example"
End If
End Sub
Private Sub List2_AfterUpdate()
Dim Criteria As String
Dim ctl As Control
Dim Itm As Variant
' Build a list of the selections.
Set ctl = Me.List2
For Each Itm In ctl.ItemsSelected
If Len(Criteria) = 0 Then
Criteria = ctl.ItemData(Itm)
Else
Criteria = Criteria & "," & ctl.ItemData(Itm)
End If
Next Itm
Me.txtCriteria1 = Criteria
End Sub
this is the code I have been using... do I need to alter the query the report is based on somehow?