Could any please explain why the following isn't working?
It seems to fail on the Where clause of the SQL when attempting to open the recordset. However in debug [Forms]![frmMainBuildBOM]![ProductID] has a value. The code is executed from frmMainBuildBOM - ie the form is open.
Error message reads:
'error 3061 Too few parameters. Expected 1'
Thanks
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
strSQL = "SELECT tblConponent.ConponentID, tblConponent.ParentProductID, tblConponent.Quantity, tblProduct.ProductName, tblConponent.Notes " & vbCrLf & _
"FROM tblConponent INNER JOIN tblProduct ON tblConponent.ConponentID = tblProduct.ProductID " & vbCrLf & _
"WHERE (((tblConponent.ParentProductID)= [Forms]![frmMainBuildBOM]![ProductID]));"
Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL)
It seems to fail on the Where clause of the SQL when attempting to open the recordset. However in debug [Forms]![frmMainBuildBOM]![ProductID] has a value. The code is executed from frmMainBuildBOM - ie the form is open.
Error message reads:
'error 3061 Too few parameters. Expected 1'
Thanks
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSQL As String
strSQL = "SELECT tblConponent.ConponentID, tblConponent.ParentProductID, tblConponent.Quantity, tblProduct.ProductName, tblConponent.Notes " & vbCrLf & _
"FROM tblConponent INNER JOIN tblProduct ON tblConponent.ConponentID = tblProduct.ProductID " & vbCrLf & _
"WHERE (((tblConponent.ParentProductID)= [Forms]![frmMainBuildBOM]![ProductID]));"
Set db = CurrentDb
Set rst = db.OpenRecordset(strSQL)