Thanks but my form isn't bound to any recordset. I'm not sure how the query above applies.
Main Topics
Browse All TopicsI am getting an error trying to insert these fields from an Access form into a table. When I step through the SQL is picking up the correct values but on my db.Execute (strSQL) I am getting a "Too Few Parameters - Expected 3" error. Am I missing something?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
This error normally means you have used incorrect spellings for your field names.
However there could be other issues here because ther are certainely other errors in the sql.
Try...
strSQL = "INSERT INTO Table1 (PartName, PartClass, PartDate, PartUserID) VALUES ('" & Me.txtPartName & "', '" & Me.txtPartClass & "',# " & Me.txtPartDate & "#, " & Me.txtPartUserID & ")"
this assumes that Partname and Partclass are text and PartUserId is numeric.
ALos
remove the brackets from
db.Execute (strSQL)
and delete the line that says
db.close
Business Accounts
Answer for Membership
by: DatabaseMXPosted on 2009-09-15 at 09:52:22ID: 25336904
Courtesy of EE's mbizup:
frmTest].[ txtEmpID]) );
rametersTe st") est].[txtE mpID]") = ([Forms]![frmTest].[txtEmp ID]) ID]) et)
"References to form controls work fine in stored queries. If you take that same query and open it through VBA, the same form reference that worked before will cause an error -- unless you evaluate that reference seperately. This holds true for OpenRecordset statements, and also CurrentDB.Execute and Docmd.RunSQL."
ok ... here is the example.
Setup:
A form with RecordSource of tblEmp (employees table - two fields EmpID, EmpName)
Textbox on the form bound to EmpID
A saved Query Def (qryParametersTest) in the database window with this SQL:
SELECT tblEmp.EmpID, tblEmp.EmpName
FROM tblEmp
WHERE (((tblEmp.EmpID)=[Forms]![
This function:
Public Function mQyrParmTest() As Boolean
Dim rst As DAO.Recordset, qdf As DAO.QueryDef
Set qdf = CurrentDb.QueryDefs("qryPa
With qdf
.Parameters("[Forms]![frmT
' or Parameters(0) = ([Forms]![frmTest].[txtEmp
Set rst = .OpenRecordset(dbOpenDynas
MsgBox rst![EmpName] 'this will display the Employee name related to the ID currently on the form
End With
Set rst = Nothing
Set qdf = Nothing
End Function
------
mx