What does this code mean?

J

Jasper Recto

Some body sent me the following code to create a table but I'm not sure what
each part means and where I'm supposed to enter this. Can somebody explain
to me what I'm supposed to do with code:

First create a table called tblBOM

db.Execute "CREATE TABLE tblBOM " _

" (idsBomID Long, strTopLevelPart Text(20), lngLevel Long,
strParentPartNum Text(20), " & _

"strParentRev Text (10), strMtlPartNum Text(20), strMtlRev
Text (10), dblQuantity Double, " & _

"dblParentQuantity Double, dblTotal Double)"

Thanks,
Jasper
 
P

pietlinden

Some body sent me the following code to create a table but I'm not sure what
each part means and where I'm supposed to enter this.  Can somebody explain
to me what I'm supposed to do with code:

First create a table called tblBOM

db.Execute "CREATE TABLE tblBOM " _

" (idsBomID Long, strTopLevelPart Text(20), lngLevel Long,
strParentPartNum Text(20), " & _

"strParentRev Text (10), strMtlPartNum Text(20), strMtlRev
Text (10), dblQuantity Double, " & _

"dblParentQuantity Double, dblTotal Double)"

Thanks,
Jasper

In a subroutine in code module. it's Data Definition SQL. It creates
a table.
 
D

Douglas J. Steele

That's known as DDL (Data Definition Language), a way of defining tables,
fields, indexes and relationships through queries.

That specific code creates a table named tblBOM with ten fields named
idsBomID (a Long Integer), strTopLevelPart (a 20 character Text field),
lngLevel (a Long Integer), str PaternPartNum (a 20 character Text field),
strParentRev (a 10 character Text field), strMtlPartNum (a 20 character Text
field), strMtlRev (a 10 character Text field), dblQuantiy (a Double),
dblParentQuantity (a Double) and dblTotal (a Double).

It's not creating any index on the table, nor is the table defined as being
involved in any relationships.

That's a VBA statement (it uses the Execute method of the DAO Database
object), so you'd put it in a sub or function and call it. Note that it's
necessary to instantiate db before that code will work. In other words, you
need the following two lines before that line:

Dim db As DAO.Database

Set db = CurrentDb()
 
D

Douglas J. Steele

Already answered in another newsgroup to which you posted the same question
(microsoft.public.access)

If you feel you need to post to more than one group (HINT: it's seldom
necessary), please have the courtesy to cross-post (send the one message to
all groups at once), rather than multi-post (send individual messages to
each group). In this way, all responses to your post will be available
together, regardless of what group the responder was in, and the rest of us
won't have to read your post multiple times. (It also uses fewer server
resources)

I see you're using Outlook Express. Click the "Newsgroups:" label to the
left of the box containing the name of the current newsgroup. That will open
a dialog that will let you add additional newsgroups to your post.

Note that it's generally consider to be A Bad Thing to cross-post to more
than about 2 or 3 newsgroups.
 
Top