PDA

Click to See Complete Forum and Search --> : Trouble creating an Access table with VB6


Dan0331
Jan 3rd, 2000, 10:14 PM
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?

Mark Sreeves
Jan 3rd, 2000, 10:19 PM
Can I have a look at your code?


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

Mark.Sreeves@Softlab.co.uk
A BMW Group Company

Dan0331
Jan 4th, 2000, 11:34 AM
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!

Dan0331
Jan 4th, 2000, 11:50 AM
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!

MartinLiss
Jan 4th, 2000, 11:55 AM
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] [, 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.

------------------
[i]Marty

LG
Jan 4th, 2000, 11:57 AM
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