VBA - RunSQL Command 
Author Message
 VBA - RunSQL Command

I have code that does a DoCMD.RunSQL( insert....)  My
problem is that the table records never get inserted in,
but the auto ID field increments by the number of records
I'm trying to insert.  I've also tried

dim dbs as database
set dbs = currentdb

dbs.execute ( insert.....)

Any ideas?



Mon, 10 Jan 2005 05:05:56 GMT  
 VBA - RunSQL Command
Make sure and add the optional dbFailOnError or you will not get any failure
notification.

dbs.execute "insert.....", dbFailOnError

Probably need to paste the sql into the query grid to see your error...

Dim strSql As String
strSql = "insert....."

Debug.Print strSql
Stop

'now copy and paste the code from the immediate window into a new query
(View/Sql)

Steve


Quote:
> I have code that does a DoCMD.RunSQL( insert....)  My
> problem is that the table records never get inserted in,
> but the auto ID field increments by the number of records
> I'm trying to insert.  I've also tried

> dim dbs as database
> set dbs = currentdb

> dbs.execute ( insert.....)

> Any ideas?



Mon, 10 Jan 2005 05:20:01 GMT  
 VBA - RunSQL Command
Hi Jay

Try:
dbs.Execute "Insert .... ", dbFailOnError

This will give you a trappable error signifying the reason for the failure.

--
Good Luck!
Graham Mandeno [Access MVP]
Auckland, New Zealand

Return mail address is invalid in a vain attempt to reduce spam.

Please post new questions or followups to newsgroup.


Quote:
> I have code that does a DoCMD.RunSQL( insert....)  My
> problem is that the table records never get inserted in,
> but the auto ID field increments by the number of records
> I'm trying to insert.  I've also tried

> dim dbs as database
> set dbs = currentdb

> dbs.execute ( insert.....)

> Any ideas?



Mon, 10 Jan 2005 05:20:07 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Using SQL too large for Macros in RUNSQL command

2. Format a RunSQL Statement in VBA

3. Newby VBA and RunSQL

4. DoCmd.RunSQL

5. DoCmd.RunSQL Error

6. DoCmd.RunSQL error 2

7. RunSQL question

8. docmd.RunSql problem

9. docmd.RunSQL String Concatenation

10. DoCmd.RunSQL too long record

11. DoCmd.RunSQL

12. More RunSQL issues

 

 
Powered by phpBB® Forum Software