All I said was that I don't know how to use the syntax. A search in VBA
help for "CREATE TABLE" turns up not a single result. Turns out it is in
regular Access help, so it's not a VBA thing. That would have been helpful
to know, especially when it was so clear I was heading down the wrong road.
Anyhow, I found the ANSI-92 mode, and changed to that, and created one of
the three tables in your code by pasting into a query. The other two had a
syntax error and something else about not finding the table or constraint.
I have bookmarked the articles, and will study them when I can. For a
syntax for creating tables see my latest response to the OP in this thread.
No doubt CREATE TABLE is a fine thing, but it's not especially helpful when
it's so difficult to glean enough information to learn how to implement it.
[Jamie's] code may well establish the tables and relationships, but I
have to admit I can't figure out what to do with his CREATE TABLE code. I
probably should, but it does not seem to be documented in Access Help, and
everything else I have been able to find about it assumes advance
knowledge
of what to do with it.
Some general points:
· 'CREATE TABLE' syntax, a subset of SQL DDL, has been in Jet since at
least version 2, hence for at least 12 years; and is documented in the
Access Help; if you are experiencing difficulties in finding it,
here's a URL (Access2003 Help):
http://office.microsoft.com/en-gb/access/CH010410161033.aspx
· The enhanced Jet 4.0 SQL DDL (e.g. to include CHECK constraints) I
posted here has been in Jet since version 4.0, hence at least six
years, and has been available via the Access user interface (UI) since
Access2002, hence at least four years. If it is new to you, see:
Intermediate Microsoft Jet SQL for Access 2000
http://msdn2.microsoft.com/en-us/library/aa140015(office.10).aspx
(Note it's classed as 'intermediate' rather than 'advanced').
· To use Jet 4.0 SQL DDL in the Access UI you must put the database
into ANSI-92 Query Mode (which I name-checked in my original post)
which is documented in the Access Help; if you are experiencing
difficulties in finding it, here's a URL:
http://office.microsoft.com/en-gb/access/HP030704831033.aspx
· Posting SQL DDL is considered netiquette in other SQL groups and is
a very efficient way of describing a schema (table structure) in a
newsgroup posting.
As regards the SQL DDL I posted, you can execute each SQL DDL
statement (delimited by semicolons) while in ANSI-92 Query Mode and
examine the results in the Access UI.
[I used to always wrap my SQL DDL in an short VBA routine, using ADO
to execute each statement, but I got no feedback so I stopped doing so
every time because it takes several minutes.]
Alternatively, and perhaps the better approach, is to examine the code
and recreate the database objects using the Access UI: there's a
designer for tables where a UNIQUE constraint can be implemented using
an 'index' and a CHECK constraint may be implemented via 'field'
Validation Rule, whereas a FOREIGN KEY can be defined using 'drag and
drop' in the Relationships window
....although I have the impression you're my grandmother, BruceM, and
I'm describing how eggs may be sucked <g>, in which case here's a
challenge: describe in words how I can create the same tables,
constraints and relationships i.e. avoiding SQL DDL. Bear in mind my
original post took about ten minutes in total.
Jamie.
--