Roger's Access Library Homepage
Forum Home Forum Home > Roger's Access Library > Roger's Download Samples
  New Posts New Posts RSS Feed - SQLDAOLoader.mdb (advanced)
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Please consider donating $1 per sample downloaded, (find out why here)

SQLDAOLoader.mdb (advanced)

 Post Reply Post Reply
Roger Carlson View Drop Down
Microsoft MVP
Microsoft MVP

Joined: 20 Feb 2008
Status: Offline
Points: 261
Post Options Post Options   Thanks (0) Thanks(0)   Quote Roger Carlson Quote  Post ReplyReply Direct Link To This Post Topic: SQLDAOLoader.mdb (advanced)
    Posted: 22 Jul 2008 at 10:28pm

Please consider donating $1 per sample downloaded, find out why here.


This sample shows how to modify the structure of a Back-End database using SQL DDL (data definition language) statements and DAO code.  This sample does much the same as "SQLLoader.mdb", but does not require text files to hold the SQL.  Further, it utilizes DAO to accomplish some tasks that Access SQL does not allow, like Default Values (and other field attributes), creating Autonumber and Hyperlink fields, and modifying Field Names.

All of the code is stored in modules this sample and behind this form.  The changes are stored in the UpdateSteps table also in this database.  Each record in UpdateSteps has the name of a subroutine and the necessary arguments.  They are as follows:

RunSQLDDL: a SQL String
RunModifyFieldName: Tablename, OldFieldName, NewFieldName
RunSetDefaultValue:Tablename, FieldName, DefaultValue
RunSetRequired: Tablename, FieldName, True/False
RunSetZeroLength: Tablename, FieldName, True/False
RunCreateAutoNumber:Tablename, FieldName
RunCreateHyperText:Tablename, FieldName
RunSetAutonumberPrimaryKey: Tablename, FieldName

Not ALL table properties are addressed above (ValidationRule and ValidationRuleText being two), but the process would be similar.  Autonumber and Hypertext attributes cannot be set programmatically after the table has been appended to the Tables collection.  Therefore, you have to create the field and set the Autonumber (or hypertext) attribute at the same time.   THEN set the primary key constraint.

Access 97 (89 KB):
Access 2000 DAO (98 KB): uploads/5/
Consider donating $1 per sample downloaded, find out why here.<
Back to Top
Sponsored Links

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.03
Copyright ©2001-2019 Web Wiz Ltd.