Problem with query in ADO code

B

Becky

Hi - I am running the following code:
Dim gdb As ADODB.Connection
Set gdb = New ADODB.Connection
Set gdb = CurrentProject.Connection
gdb.Execute "DELETE * from tbl_appendix_1;"
gdb.Execute "qry_app_appendix_1"

This code does empty the table but it does not populate it with any data. I
can run the exact same query by double-clicking on it and it will populate
the table - it just won't when I run it via code.

Any ideas why the code isn't working? I've used similar code before without
a problem.

Thanks!
 
K

Ken Snell [MVP]

May be a timing issue.

Try inserting
DoEvents
code step between the two query steps.


gdb.Execute "DELETE * from tbl_appendix_1;"
DoEvents
gdb.Execute "qry_app_appendix_1"
 
Top