This procedure will transfer a table definition plus data from one database to another. Manually copying objects such as tables, forms, reports, modules etc from one database to another database is simple but unnecessary and time consuming. This can be achieved quickly with these few lines of code. This code is used in MAARS implementation. Feel to free use it in your own program, however, please give proper credit to the MAARS team.
Public Sub TransferATableStructureAndDataToAnotherDB(srcTableName As String, destTableName As String, _
destDbFullPath As String)
'Export only the table definition to the destination database
If Dir(destDbFullPath) <> "" Then
DoCmd.TransferDatabase acExport, "Microsoft Access", destDbFullPath, acTable, srcTableName, destTableName, False
End If
End Sub
This is a complimentary article written by the MAARS team for the MAARS user community. Code in this article drives the operation of MAARS (MS Access Application wRiting Software). MAARS is an intelligent automation program that speeds up MS Access Application Development by 10x, 20x or 100x times. To learn more about MAARS, click here.
Disclaimer:
Some information included in this article may have been sourced from other publicly available websites and blogs. In such cases, credit goes to those authors for the original ideas and thoughts, but we do take credit for putting valuable information together and improve the efficiency of other office developers.
Is there anyway to transfer the table definition only?
Yes, all you have to do is set the 7th parameter (StructureOnly) to True. Syntax for this call is –
Generally I don’t read post on blogs, but I would like to say that this write-up very forced me to try and do it! Your writing style has been amazed me. Thanks, very nice article.
It抯 really a great and useful piece of information. I am glad that you just shared this useful information with us. Please stay us up to date like this. Thank you for sharing.
Thanks! I am glad you found the information helpful.
Hey there! I’m at work browsing your blog from my new iphone 3gs! Just wanted to say I love reading your blog and look forward to all your posts! Keep up the superb work!
Thanks for the feedback!
Woah! I’m really enjoying the template/theme of this blog. It’s simple, yet effective. A lot of times it’s hard to get that “perfect balance” between user friendliness and appearance. I must say you have done a fantastic job with this. Additionally, the blog loads super fast for me on Opera. Excellent Blog!
Hi:
Thanks for your positive feedback on the site. Honestly, I have not been very active maintaining it (other priorities in life got on the way). I have been getting a lot of similar feedback like yours, so I plan to become more active. Please let me know if I can help with anything.