Again, I created the append query in Query Design View, in one of its fields
i typed the criteria [Type your Code] so when the query runs certain records
are added to a table based on the code typed.
When I run the query from the design view or by opening it, the query runs
OK and adds the expected records. My next step is to create a button in a
form that will run the query so users can add their data when they entered
their code.
My mistake, I type the wrong query name, I corrected already and try to run
again via the command button on my form. Now, I got the following error
message:
Too few parameters. Expected 1
I apologize for being so (fill-in the blank).
I checked the The SQL code and it does start with INSERT INTO .
Once again, thank you.
Klatuu said:
It is not the code I posted that is the problem.
First, MyAppendQueryNameGoesHere should be replaced with the name of your
query.
Now, lets be sure this is an Action Query. You Said it is an Append query,
so it should start with INSERT INTO. If it does not, it is not an append
query.
:
Klatuu,
I typed the code that you suggested but now I got the error:
"Invalid SQL statement: expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT',
or 'UPDATE'
I typed , UPDATE after the command line but it did not work.
Help again.
Thank you
:
wizards are really pretty dumb. The OpenQuery method is for Select Queries.
All you need to do is put this in the Click event of the command button.
(Using the code builder, not directly in the text box)
CurrentDb.Execute("MyAppendQueryNameGoesHere"), dbFailOnError
:
I created an Append query containing a parameter on one of its fields. No
problem here, it runs and appends the records based on the typed parameter.
The problem is that I want to create a command button that will run this
query. The following partial code was created by the Command button wizard:
stDocName = "My Append Query"
coCmd.OpenQuery stDocName, acNormal, acEdit
When I clcik on the command button to run the query the message "Object
required" is displayed. I am stuck.
Any help? thank you.