running SQL in the VBA code

I

iccsi

strMYSQL = "INSERT INTO tblTmpMonthChart " & _
" SELECT [SP GET CSR CURRENT CHART].* " & _
" FROM [SP GET CSR CURRENT CHART];"

Debug.Print strMYSQL
CurrentDb.Execute strMYSQL, dbFailOnError


I have above VBA code to excute an INSERT query.
The SQL works and copy from debug Windows works too.

I got too few parameteres. expected 0 while I run in the VBA code.

Any suggestions for this issue?

Your help is great appreciated,
 
I

inungh

When doing an append query like this one, I believe you have to explicitly
define each of the fields to be appended.  It looks something like:

strMySQL = "INSERT INTO tblTmpMonthChart (Field1, Field2, Field3) " _
                & "SELECT Field1, Field2, Field3 " _
                & "FROM [SP GET CSR CURRENT CHART]"

This can be a real pain when trying to copy records from a table with a large
number of fields.

HTH
Dale




strMYSQL = "INSERT INTO tblTmpMonthChart " & _
    " SELECT [SP GET CSR CURRENT CHART].* " & _
    " FROM [SP GET CSR CURRENT CHART];"
 Debug.Print strMYSQL
 CurrentDb.Execute strMYSQL, dbFailOnError
I have above VBA code to excute an INSERT query.
The SQL works and copy from debug Windows works too.
I got too few parameteres. expected 0 while I run in the VBA code.
Any suggestions for this issue?
Your help is great appreciated,

--
HTH

Dale Fye

Message posted via AccessMonster.comhttp://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200906/1- Hide quoted text -

- Show quoted text -

Thanks for helping,
I am not sure that I must use DoCmd.OpenQuery to excute a save query
to make it work.

Thanks again,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top