I'm trying to run a DAO recordset when a value gets updated on a form in MS Access 97.
When I run the code i get the following error:
Run-time error '3061':
Too few parameters. Expected 1.
I experimented with alot of options and I discovered that If I write a much simplier SQL statement (Select * From table), I won't get an error. Based on what I'm doing, I would really like to get my recordset to work with the large sql code above, but if not, then maybe someone can help me rethink my methods to solve what I need to get done.
Here is what I'm trying to accomplish. I have 2 tables. A Work Order History table and a Machine Work Order History Table. The form uses the Machine Table, so all of the controls are related to its fields. When the user enters a number into one of those fields, I need to run a query to pull data out of the Work Order History table, and then put the data into some of the controls on the form. So I figured I would run a recordset that would query my data in vba then I would be able to put what I want into whatever control I wanted. Does that make sense? I hope so.
if anyone can help me out I would really appreciate it.
Thanks alot
-Keith
Code:
Dim rstTemp As DAO.Recordset
strSQL = "SELECT [WORK ORDER HISTORY].[INCIDENT NO], [WORK ORDER HISTORY].machine, [WORK ORDER HISTORY].DESCRIPTION, [WORK ORDER HISTORY].dept, EMPLOYEES.EMPLOYEE, [WORK ORDER HISTORY].[work completed] FROM [WORK ORDER HISTORY] INNER JOIN EMPLOYEES ON [WORK ORDER HISTORY].[ASSIGNED TO] = EMPLOYEES.EMPLOYEE_NAME WHERE ((([WORK ORDER HISTORY].[INCIDENT NO])=[Forms]![Maintenance WO Update]![Ticket#]))"
Set rstTemp = CurrentDb.OpenRecordset(strSQL)
When I run the code i get the following error:
Run-time error '3061':
Too few parameters. Expected 1.
I experimented with alot of options and I discovered that If I write a much simplier SQL statement (Select * From table), I won't get an error. Based on what I'm doing, I would really like to get my recordset to work with the large sql code above, but if not, then maybe someone can help me rethink my methods to solve what I need to get done.
Here is what I'm trying to accomplish. I have 2 tables. A Work Order History table and a Machine Work Order History Table. The form uses the Machine Table, so all of the controls are related to its fields. When the user enters a number into one of those fields, I need to run a query to pull data out of the Work Order History table, and then put the data into some of the controls on the form. So I figured I would run a recordset that would query my data in vba then I would be able to put what I want into whatever control I wanted. Does that make sense? I hope so.
if anyone can help me out I would really appreciate it.
Thanks alot
-Keith