Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It is possible to do a little with VBA. For example, here is a start on creating script for a database with local tables.</p> <pre class="lang-vba prettyprint-override"><code>Dim db As Database Dim tdf As TableDef Dim fld As DAO.Field Dim ndx As DAO.Index Dim strSQL As String Dim strFlds As String Dim strCn As String Dim fs, f Set db = CurrentDb Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.CreateTextFile("C:\Docs\Schema.txt") For Each tdf In db.TableDefs If Left(tdf.Name, 4) &lt;&gt; "Msys" Then strSQL = "strSQL=""CREATE TABLE [" &amp; tdf.Name &amp; "] (" strFlds = "" For Each fld In tdf.Fields strFlds = strFlds &amp; ",[" &amp; fld.Name &amp; "] " Select Case fld.Type Case dbText 'No look-up fields strFlds = strFlds &amp; "Text (" &amp; fld.Size &amp; ")" Case dbLong If (fld.Attributes And dbAutoIncrField) = 0&amp; Then strFlds = strFlds &amp; "Long" Else strFlds = strFlds &amp; "Counter" End If Case dbBoolean strFlds = strFlds &amp; "YesNo" Case dbByte strFlds = strFlds &amp; "Byte" Case dbInteger strFlds = strFlds &amp; "Integer" Case dbCurrency strFlds = strFlds &amp; "Currency" Case dbSingle strFlds = strFlds &amp; "Single" Case dbDouble strFlds = strFlds &amp; "Double" Case dbDate strFlds = strFlds &amp; "DateTime" Case dbBinary strFlds = strFlds &amp; "Binary" Case dbLongBinary strFlds = strFlds &amp; "OLE Object" Case dbMemo If (fld.Attributes And dbHyperlinkField) = 0&amp; Then strFlds = strFlds &amp; "Memo" Else strFlds = strFlds &amp; "Hyperlink" End If Case dbGUID strFlds = strFlds &amp; "GUID" End Select Next strSQL = strSQL &amp; Mid(strFlds, 2) &amp; " )""" &amp; vbCrLf &amp; "Currentdb.Execute strSQL" f.WriteLine vbCrLf &amp; strSQL 'Indexes For Each ndx In tdf.Indexes If ndx.Unique Then strSQL = "strSQL=""CREATE UNIQUE INDEX " Else strSQL = "strSQL=""CREATE INDEX " End If strSQL = strSQL &amp; "[" &amp; ndx.Name &amp; "] ON [" &amp; tdf.Name &amp; "] (" strFlds = "" For Each fld In tdf.Fields strFlds = ",[" &amp; fld.Name &amp; "]" Next strSQL = strSQL &amp; Mid(strFlds, 2) &amp; ") " strCn = "" If ndx.Primary Then strCn = " PRIMARY" End If If ndx.Required Then strCn = strCn &amp; " DISALLOW NULL" End If If ndx.IgnoreNulls Then strCn = strCn &amp; " IGNORE NULL" End If If Trim(strCn) &lt;&gt; vbNullString Then strSQL = strSQL &amp; " WITH" &amp; strCn &amp; " " End If f.WriteLine vbCrLf &amp; strSQL &amp; """" &amp; vbCrLf &amp; "Currentdb.Execute strSQL" Next End If Next f.Close </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload