M
martinmike2
Hello,
I am sorry to ask this question when it has alreayd been asked several
times before, but I am having issues figuering out the code to
accomplish this.
my code is:
Private Sub Command2_Click()
Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String
Dim rst As DAO.Recordset
Set frm = Forms!frmAMDsel
Set ctl = frm!LstWC
strSQL = "WHERE qryAMDSEAsub.WC ="
'Assuming long [EmpID] is the bound field in lb
'enumerate selected items and
'concatenate to strSQL
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem)
Next varItem
'Trim the end of strSQL
'strSQL = (Left$(strSQL, Len(strSQL) - 12))
DoCmd.OpenReport "rptAMD_SeaDuty", acViewPreview, , strSQL
End Sub
Now, when i click to command button i get:
Run-Time error (3075): Syntax Error (missing operator) in query
expression.
Am I just being stupid with my SQL statement? Do I need to provide
the full query in the reports where property?
I am sorry to ask this question when it has alreayd been asked several
times before, but I am having issues figuering out the code to
accomplish this.
my code is:
Private Sub Command2_Click()
Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String
Dim rst As DAO.Recordset
Set frm = Forms!frmAMDsel
Set ctl = frm!LstWC
strSQL = "WHERE qryAMDSEAsub.WC ="
'Assuming long [EmpID] is the bound field in lb
'enumerate selected items and
'concatenate to strSQL
For Each varItem In ctl.ItemsSelected
strSQL = strSQL & ctl.ItemData(varItem)
Next varItem
'Trim the end of strSQL
'strSQL = (Left$(strSQL, Len(strSQL) - 12))
DoCmd.OpenReport "rptAMD_SeaDuty", acViewPreview, , strSQL
End Sub
Now, when i click to command button i get:
Run-Time error (3075): Syntax Error (missing operator) in query
expression.
Am I just being stupid with my SQL statement? Do I need to provide
the full query in the reports where property?