You didn't say, but is this in code, or the query?
...(Suppliers INNER JOIN Products ON Suppliers.SID ='" & SupplierID & "' and Products.ProductType ='" & ProductID & "')...
I can't tell if SupplierID and ProductID are supposed to be variables.
In any event, they are probably integers, in which case, if this is cast properly, it would be:
...(Suppliers INNER JOIN Products ON Suppliers.SID =" & SupplierID & " AND Products.ProductType =" & ProductID & ")...
Remove the single quotes since those are only used when the value is not numeric, which I assume it is here.
Given that it is a numeric value, and you are taking it from somewhere, which you don't show since you didn't post the code, it should at least be:
...(Suppliers INNER JOIN Products ON Suppliers.SID =" & Me.SupplierID & " AND Products.ProductType =" & Me.ProductID & ")...
HOWEVER, Access gets freaky when you try to pass values from the form directly into SQL strings at run time, so I am guessing this is the cause of the error. I would do this:
Dim iSuppID, iProdID As Integer
Dim sSQL As String
iSuppID = Me.SupplierID
iProdID = Me.ProductID
sSQL = "SELECT Products.PID, SPrice.PID, Products.SID, Suppliers.[Name], Products.[Description], Products.ProductType, SPrice.MinQuan, SPrice.Currency, SPrice.Price, SPrice.Type, SPrice.SDate FROM (Suppliers INNER JOIN Products ON Suppliers.SID =" & iSuppID & " AND Products.ProductType =" & iProdID & ")INNER JOIN SPrice ON Products.PID = SPrice.PID"
Me.ExportSPriceToExcel_subform.Form.Recordsource = sSQL
The closing semicolon is not necessary.
Did any of that help?
mmcdonal
|