As it stands this is what I am trying to do. I'm trying to read a value from a combo box in a form and then choose the price corresponding to this value from a table so I can then do a calculation based on this price. This is my code,
Dim materialCost As Double
Dim strSQL As String
Dim rst As DAO.Recordset
strSQL = "SELECT MaterialT.EuroCostPerWeight FROM MaterialT WHERE MaterialT.MaterialName =[Forms]![CustomComponentF]![C_MaterialCmb].[Value]"
Set rst = CurrentDb.OpenRecordset(strSQL)
materialCost = rst!EuroCostPerWeight
rst.Close
Set rst = Nothing
I preform the calculation on the materialCost variable. The SQL command works, I've checked it and I get the right result and if I manually write in the value in the form the above code works. But when I do it this way I get the error. Any ideas?
Dim materialCost As Double
Dim strSQL As String
Dim rst As DAO.Recordset
strSQL = "SELECT MaterialT.EuroCostPerWeight FROM MaterialT WHERE MaterialT.MaterialName =[Forms]![CustomComponentF]![C_MaterialCmb].[Value]"
Set rst = CurrentDb.OpenRecordset(strSQL)
materialCost = rst!EuroCostPerWeight
rst.Close
Set rst = Nothing
I preform the calculation on the materialCost variable. The SQL command works, I've checked it and I get the right result and if I manually write in the value in the form the above code works. But when I do it this way I get the error. Any ideas?