Results 1 to 6 of 6

Thread: Trouble creating an Access table with VB6

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 1999
    Location
    alb, nm 87112
    Posts
    56

    Post


    Hi Everyone,

    I was given some code to do this yesterday, however I ran in to a problem. When I use the
    same format that was posted, changing the names, and lengths to suit the table I need I
    get an error message when I move to the next line.

    "Expected end of statement" with the name of the table to be created highlighted.

    Any suggestions?

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845

    Post

    Can I have a look at your code?


    ------------------
    Mark Sreeves
    Analyst Programmer

    [email protected]
    A BMW Group Company

  3. #3

    Thread Starter
    Member
    Join Date
    Nov 1999
    Location
    alb, nm 87112
    Posts
    56

    Post

    Hi Mark,

    Here's the code. It's a routine that was posted for me yesterday. It's just the basic "Create Table" function.

    Create Table Monthly (Name text [(50)]

    The online book I found uses the exact same text, but I continue to receive the error on the table name.

    Thanks!

  4. #4

    Thread Starter
    Member
    Join Date
    Nov 1999
    Location
    alb, nm 87112
    Posts
    56

    Post

    Ok, I was able to get rid of the "end of statement" message, but now I'm getting a Variable not Defined with the following:

    Create Table = Month(Name, Text, [(50)])

    I appreciate your time!


  5. #5
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    here is the Help for Create Table from MSDN. Some of the parameters you are attempting to use are variables that you need to Dim (and Dim properly).

    Creates a new table.

    Note The Microsoft Jet database engine doesn't support the use of CREATE TABLE, or any of the DDL statements, with non-Microsoft Jet database engine databases. Use the DAO Create methods instead.

    Syntax

    CREATE TABLE table (field1 type [(size)] [NOT NULL] [index1] [, field2 type [(size)] [NOT NULL] [index2] [, ...]] [, CONSTRAINT multifieldindex [, ...]])

    The CREATE TABLE statement has these parts:

    Part Description
    table The name of the table to be created.
    field1, field2 The name of field or fields to be created in the new table. You must create at least one field.
    type The data type of field in the new table.
    size The field size in characters (Text and Binary fields only).
    index1, index2 A CONSTRAINT clause defining a single-field index. See the CONSTRAINT clause topic for more information on how to create this index.
    multifieldindex A CONSTRAINT clause defining a multiple-field index. See the CONSTRAINT clause topic for more information on how to create this index.
    Remarks

    Use the CREATE TABLE statement to define a new table and its fields and field constraints. If NOT NULL is specified for a field, then new records are required to have valid data in that field.
    A CONSTRAINT clause establishes various restrictions on a field, and can be used to establish the primary key. You can also use the CREATE INDEX statement to create a primary key or additional indexes on existing tables.
    You can use NOT NULL on a single field, or within a named CONSTRAINT clause that applies to either a single field or to a multiple-field named CONSTRAINT. However, you can apply the NOT NULL restriction only once to a field, or a run-time error occurs.


    ------------------
    Marty

  6. #6
    Hyperactive Member
    Join Date
    Jun 1999
    Posts
    308

    Post

    Hi,there.

    In your code remove (,)after Text. Text is variable type

    Create Table = Month(Name, Text(50))

    And I think you don't need square brackets.
    Month is your table name,
    Name is your field's name of variable type Text, 50 characters long.

    Good luck
    Larisa


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width