Sunday, September 13, 2009

Ab-normalization at Experts Exchange - part 17

Question today: If table exist

The problem:
The questioner wants to add new tables, but runs into trouble when a table does exist...


The crappy solution:

if dcount("[name]","msysobjects","[name]='Table1'")>0 then
DoCmd.DeleteObject acTable, "Table1"
end if

Obviously capricorn1 doesn't know that the normally hidden "msys" tables are owned by Microsoft and that they can change the names and/or structure as they please.
So it's bad coding to use these tables and there's no need to use them, as the Access objects will enable you to check for the existance of a table in the tables collection.

Three "proper" samples can be found at:
http://forums.devarticles.com/microsoft-access-development-49/access-2000-delete-a-table-if-it-exists-using-code-3821.html


Nic;o)
Still proud to be suspended from this "quality site" where wannabee experts rule and "quality" is just another word from the dictionary.
(The question can be found at: http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_24726902.html)

No comments:

Post a Comment