Previewing a report filtered on values selected from 2 list boxes

NLS

Joined
Jun 1, 2006
Messages
2
Reaction score
0
Please can someone help?!

I have a form with 2 List boxes (List39 and List14) and a Preview Report Button (btnContTypeClass). I need the user to click on a value in each of the List boxes and then press the button to preview a report showing all the records with the vaules in List 39 AND List41. I have the following code but I am not sure if I have missed something or got the syntax wrong:

Option Compare Database
Dim contactselect As String
Dim Classselect2 As String

Private Sub List39_Click()
Classselect2 = List39.Value
End Sub
Private Sub List41_Click()
contractselect = List41.Value
End Sub

Private Sub btnContTypeClass_Click()
On Error GoTo Err_btnContTypeClass_Click
Dim stDocName As String
stDocName = "ContractTypeClass_Qry"
DoCmd.OpenReport stDocName, acPreview, , "Class = '" & Classselect2 & "'" And "ContractType='" & contractselect & "'"

Exit_btnContTypeClass_Click:
Exit Sub
Err_btnContTypeClass_Click:
MsgBox Err.Description
Resume Exit_btnContTypeClass_Click

End Sub
 
Back
Top