Dynamic name of string variable (1 Viewer)

Gasman

Enthusiastic Amateur
Local time
Today, 14:59
Joined
Sep 21, 2011
Messages
14,054
Shouldn't that be :unsure:

Code:
For i = 0 To Ubound(strSQL)
'    MsgBox strSQL(i)
    CurrentDb.Execute strSQL(i), dbFailOnError
Next i
 

cheekybuddha

AWF VIP
Local time
Today, 14:59
Joined
Jul 21, 2014
Messages
2,238
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!
 

Wysy

Registered User.
Local time
Today, 07:59
Joined
Jul 5, 2015
Messages
333
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
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 14:59
Joined
Jul 9, 2003
Messages
16,245
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...
 

Minty

AWF VIP
Local time
Today, 14:59
Joined
Jul 26, 2013
Messages
10,355
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

Top Bottom