ok, I've been looking at this way to long and need another set of eyes. What is it I'm missing with this SQL? Right now I'm getting a (missing operator) in query expression. The passed variable is coming thru correct at "1" and the tabl variable is debugging correct at "1order". i have several possible recordsources and i would prefer to have this one function rather than declaring several recordsources and picking from them.
Code:
Private Function setorderrecord(num As Integer)
Dim strord As String
Dim tabl As String
tabl = num & "ordert"
Debug.Print (tabl)
strord = ("SELECT " & _
tabl & ".[order], " & _
tabl & ".[CustomerID], " & _
tabl & ".[Mill Thickness], " & _
tabl & ".[Width], " & _
tabl & ".[Length], " & _
tabl & ".[Cuts], " & _
tabl & ".[Cut_Weight], " & _
tabl & ".[Second_Cut_Weight], " & _
tabl & ".[Comments], " & _
tabl & ".[bundle], " & _
" CustomersT.[Customer] " & _
" FROM '" & tabl & "' RIGHT OUTER JOIN CustomersT " & _
" ON '" & tabl & "'.[CustomerID] = CustomersT.[CustomerID]; ")
Debug.Print (strord)
Forms!prodf.SubOrderF.Form.RecordSource = strord
Forms!prodf.Requery
End Function
the "strord" is printing as
Code:
SELECT 1ordert.[order], 1ordert.[CustomerID], 1ordert.[Mill Thickness], 1ordert.[Width], 1ordert.[Length], 1ordert.[Cuts], 1ordert.[Cut_Weight], 1ordert.[Second_Cut_Weight], 1ordert.[Comments], 1ordert.[bundle], CustomersT.[Customer] FROM '1ordert' RIGHT OUTER JOIN CustomersT ON '1ordert'.[CustomerID] = CustomersT.[CustomerID];
versus the original as
Code:
StrOrder1 = "SELECT [1OrderT].[PO/WO#], [1OrderT].CustomerID, [1OrderT].[Mill Thickness], " & _
" [1OrderT].Width, [1OrderT].Length, [1OrderT].Cuts, [1OrderT].Cut_Weight, " & _
" [1OrderT].Second_Cut_Weight, [1OrderT].Comments, CustomersT.Customer, [1OrderT].bundle " & _
" FROM CustomersT RIGHT JOIN 1OrderT ON CustomersT.CustomerID = [1OrderT].CustomerID; "
any help is appreciated.