Dynamic name of string variable

Shouldn't that be :unsure:

Code:
For i = 0 To Ubound(strSQL)
'    MsgBox strSQL(i)
    CurrentDb.Execute strSQL(i), dbFailOnError
Next i
 
Shouldn't that be :unsure:

Code:
For i = 0 To Ubound(strSQL)
'    MsgBox strSQL(i)
    CurrentDb.Execute strSQL(i), dbFailOnError
Next i
Most definitely - thanks for the spot! I corrected the error in my post.

Time for some more coffee I think!
 
Thank you so much, this was exactly what i was looking for. #12 post did not help since the name of the tables were not table1, table 2, etc.
Once again the reason for wanted to create this code was to find a solution of emptying all the tables with a simple click while writing codes and see how it works.
thanks again
 
After a good night's sleep I realised there might be a better way to achieve what you want. I've done this video:-

Delete Tables - Nifty Access


from which you should be able to reconstruct the "DELETE TABLES FORM" yourself. Alternatively go to my website HERE:-

Delete Tables

where there's a download button. You can download a WORKING example dB containing the code. For a short time, it's available for free, using the coupon code:- free_or_buy_tony-a-coffee

If you miss the opportunity to get it for free with the coupon code:- free_or_buy_tony-a-coffee THEN Contact me, and I will provide an alternative way of getting a free copy...
 
I would put the table names into ... wait for it ... a table.
Then simply loop through them with the delete statement.

Add a boolean field to the table saying "ResetDelete" or similar, and you can populate the table automatically with all the tables in the DB using the MySysObject table, then simply set the flag on the ones you want to "Reset Delete" the contents. You could even add an ordering field so that and referential integrity is maintained, by deleting the child table records first.
 

Users who are viewing this thread

Back
Top Bottom