I have to combine data from two tables so I can use the information in a report. To do that I created a make table query from one table and an append query from the second table. Everything works except for the For Each section. This is an area I have limited experience with. What am I missing?
Dim stDocName As String
Dim strWhere As String
‘Error message if there are no selected records in the classes
If Forms!frmReports!lstClasses.ItemsSelected.Count = 0 Then
MsgBox “No classes are selected!”, vbInformation
Exit Sub
End If
For Each varItm In lstClasses.ItemsSelected
strWhere = strWhere & “, ” & Chr(34) & Me.lstClasses.ItemData(varItm) & Chr(34)
Next varItm
strWhere = “ClassName In (” & Mid(strWhere, 3) & “)”
DoCmd.SetWarnings Off
stDocName = “qryMakeTableCombined”
DoCmd.OpenQuery stDocName, acNormal, acEdit
stDocName = “qryAppendTableCombined”
DoCmd.OpenQuery stDocName, acNormal, acEdit
Thank you. Fay