please use the code tags to preserve formatting. Otherwise difficult top read and many won't bother responding - I won't after this occasion
Code:
Private Sub lstHull_AfterUpdate()
Dim myHull As String
Dim strSQL As String
Dim VarItem As Variant
'What does this do??? iterating through a multiselect listbox to collect the items selected and putting them in a comma separated string call myHull
For Each VarItem In Me!lstHull.ItemsSelected
myHull = myHull & ",'" & Me!lstHull.ItemData(VarItem) & "'"
Next VarItem
' Is this just for when a user selects multiple hulls? No - user has selected at least one hull so creates a criteria string, otherwise doesn't bother
If Len(myHull) > 0 Then
myHull = Right(myHull, Len(myHull) - 1)
strSQL = strSQL & "dbo_tblPrintCenter.hull IN (" & myHull & ") AND "'this line not required - it is used in the next block of code
End If
' I understand this is the SQL script that actually queries the table
strSQL = " SELECT * FROM dbo_tblPrintCenter WHERE "
If Len(Me!lstHull) > 0 Then strSQL = strSQL & "dbo_tblPrintCenter.hull IN ('" & Me!lstHull & "') " 'this line is doing the same as the previous bit of code
'this is just telling it to use the SQL
Me.dbo_tblPrintCenter_subform.Form.RecordSource = strSQL
Me.dbo_tblPrintCenter_subform.Form.Requery 'this line is not required, form is automatically requeried on the previous line
End Sub