Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can anyone tell me why I got an error type mismatch at run time?

Status
Not open for further replies.

CL1975

Programmer
Oct 3, 2002
5
0
0
US
here is part of the code when creating an blank db in access and I got an error type mismatch on controlnum column and I can't seem to see why it occurred.
Thanks in advance.


Dim TableCheckBook As TableDef
Dim WrkSpce As Workspace
Dim DBEng As DBEngine
Dim Fld As Field
Dim Indx As Index

Set WrkSpce = DBEngine.Workspaces(0)
Set DB = CreateDatabase(DBName, dbLangGeneral)
Set TableCheckBook = DB.CreateTableDef("CheckBook")
Set Indx = TableCheckBook.CreateIndex("ControlNumIDX")
Indx.Primary = True
Indx.Fields.Append Indx.CreateField("ControlNum")
TableCheckBook.Indexes.Append Indx
Set Fld = TableCheckBook.CreateField("ControlNum", dblong)
Fld.Attributes = dbAutoIncrField
TableCheckBook.Fields.Append Fld
Set Fld = TableCheckBook.CreateField("Date", dbDate)
TableCheckBook.Fields.Append Fld
Set Fld = TableCheckBook.CreateField("Amount", dbCurrency)
TableCheckBook.Fields.Append Fld
Set Fld = TableCheckBook.CreateField("TransactionType", dbSingle)
TableCheckBook.Fields.Append Fld
Set Fld = TableCheckBook.CreateField("CheckNum", dbLong)
Fld.Attributes = dbVariableField
TableCheckBook.Fields.Append Fld
Set Fld = TableCheckBook.CreateField("UserID", dbText, 30)
TableCheckBook.Fields.Append Fld
DB.TableDefs.Append TableCheckBook
 
Hi, maybe you should create the field frist before creading an index for that field. John
 

This...

Indx.Fields.Append Indx.CreateField("ControlNum")

should be

Indx.Fields.Append Indx.CreateField("ControlNum", dbLong)

if I read my old code right.

 
That wasn't case guys. Thanks for your effort.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top