I have scanned the net and got so may different answers, that don't work, to this question'
I am trying to replace the "From" clause with a variable in the code below.
I keep getting an error in the from clause no matter what variations I try.
I am trying to replace the "From" clause with a variable in the code below.
I keep getting an error in the from clause no matter what variations I try.
Code:
Private Sub Command100_Click()
Dim sTable As String
Dim sCommon As String
Dim rs As Recordset
Dim str As String
Set rs = oDB.OpenRecordset("TableList", dbOpenSnapshot)
With rs
.MoveFirst
Do
sTable = !TableName
' sCommon = !CommonName
str = "INSERT INTO tempfamily ( Family, Infra, BoxNo, BayNo, ShelfNo, Collect ) " & _
"SELECT Family, Infrafamily, BoxNo, BayNo, ShelfNo, BoxedAsCollection " & _
"FROM " & sTable & _
"GROUP BY Family, Infrafamily, BoxNo, BayNo, ShelfNo, BoxedAsCollection " & _
"HAVING (((BoxNo) > 0) And ((BayNo) = 0) And ((ShelfNo) = 0)) " & _
"ORDER BY Family, BoxNo, BoxedAsCollection"
DoCmd.RunSQL str
.MoveNext
Loop While Not .EOF
End With
End Sub