SQLDAOLoader.mdb (expert)

Please consider donating $1 per sample downloaded, find out why here
Download
SQLDAOLoader.zip
Access 97 (89 KB)
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

Notes:  
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. 

 

Feedback

 

Need Winzip?

Return to Main Page