Visual Basic Code of the Week (COTW)
Issue #79
Online Version at (paid subscribers only)
All content and source code is Copyright (c) 1999 by C&D Programming Corp. No part of this issue can be reprinted or distributed in any manner without express written permission of C&D Programming Corp.

Get your Free Year of Code of the Week!!!

For the next month we are offering a free annual subscription to anyone that submits source code for an issue which gets published. If you have some useful source code would be valuable for our members, fill out the form at

Please make sure all source code is tested and is in working condition. We are looking for all types of source from database access routines to API calls to graphics routines. We are not looking for one or two lines tricks at this time (this will be a future offering) . The source code should be at least 10 or 15 lines of long, preferably longer. It should be commented or at least readable by the average programmer.

If you are currently a member of Code of the Week we will extend your subscription an additional year.

Deal of the Week

Get your copy of PowerFindPro for only $19.95 (regularly $24.95). You can get full information on the product at

You can order PowerFindPro at this great price at

In this Issue

In this issue we discuss how to copy a database table structure using some standard SQL instructions.

This source code is designed for VB 3.0 and up. Questions? Email us at


The basDatabase module contains a single function that copies a the structure of a database table into another table name. It accomplishes this by using the INTO SQL clause. There is a topic in the Jetsql35.hlp that comes with Visual Basic 5.0 called "SELECT...INTO" that fully discusses the various options on this powerful statement. This routine could easily be extended to do database backups of tables. If you are interested in this, drop us an email at


Public Function CopyTableStructure(sSourceDB As String, sSourceTable As String, _
                                        sDestinationTable As String) As Boolean

Sample Usage

The below sample copies the table structure of the POS table in the database e:\temp\pos.mdb to posimport.

    If CopyTableStructure("e:\temp\pos.mdb", "pos", "posimport") Then
        MsgBox "Table copied"
        MsgBox "Table not copied"
    End If

Source Code

To see the source code for this issue you must be a subscriber to Code of the Week. If you are a subscriber the source code is available at the following address:

This document is available on the web

Paid subscribers can view this issue in HTML format. There is no additional source or information in the HTML formatted document. It just looks a little better since we have included some HTML formatting. Just point your browser to link at the top of this document.

Other links

Contact Information

C&D Programming Corp.
PO Box 20128
Floral Park, NY 11002-0128
Phone or Fax: (212) 504-7945