Cannot execute SELECT query but executing INSERT INTO query

C

cjohnson300

Hi, I am trying to execute an INSERT INTO query using the command qdf.Execute
and the SQL string I am using is the following:
"PARAMETERS [Job Number] CHAR, [Invoice Number] CHAR, [Invoice Date]
datetime; INSERT INTO tblInvoices (JobNo, InvoiceNo, InvoiceDate) VALUES
([Job Number], [Invoice Number], [Invoice Date]);"

Every time I try to execute it, it says it cannot execute a select query.
The table is a linked ODBC table to a SQL Server 2000 database. I can
manipulate the table but just cannot make this query work. Please help!

Many thanks in advance for any comments
 
T

TPratt

I would set it up something like this...

Function TestSQL()
Dim strSQL as String
strSQL = "Your SQL String"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
End Function

Test your SQL by pasting it (or better yet creating it) in a query first.
If it works there it should work in the code above.
 

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