I have a piece of code that changes a query definition and passes some parameters into it. This works fine until I go to run the query.
The query does not return any records with the parameters until I go into the Query design and delete any of the criteria and then re-type the same value back in.
Can anybody help with this and explain why this is happening ?
Thanks
Dim SQLString As String
Dim Qry As QueryDef
Dim DB As Database
Dim SuppID As Integer
Dim SalesMonth As String
Dim CustID As String
Set DB = CurrentDb()
Set Qry = DB.QueryDefs("QrySalesAnalysis")
SuppID = cmbSupplier
SalesMonth = cmbSalesMonth
CustID = cmbCustID
SQLString = "Select [SalesValue] , [SalesMonth],[CustomerID], [SupplierID] FROM [SalesAnalysis] WHERE [SalesMonth]= " & SalesMonth & " And [CustomerID] = " & CustID & " And [SupplierID] = " & SuppID & ";"
Qry.SQL = SQLString
Qry.Close
End Function
The query does not return any records with the parameters until I go into the Query design and delete any of the criteria and then re-type the same value back in.
Can anybody help with this and explain why this is happening ?
Thanks
Dim SQLString As String
Dim Qry As QueryDef
Dim DB As Database
Dim SuppID As Integer
Dim SalesMonth As String
Dim CustID As String
Set DB = CurrentDb()
Set Qry = DB.QueryDefs("QrySalesAnalysis")
SuppID = cmbSupplier
SalesMonth = cmbSalesMonth
CustID = cmbCustID
SQLString = "Select [SalesValue] , [SalesMonth],[CustomerID], [SupplierID] FROM [SalesAnalysis] WHERE [SalesMonth]= " & SalesMonth & " And [CustomerID] = " & CustID & " And [SupplierID] = " & SuppID & ";"
Qry.SQL = SQLString
Qry.Close
End Function