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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Does anyone know why I'm getting a

Status
Not open for further replies.

RobJDB

Programmer
May 13, 2002
44
GB
Does anyone know why I'm getting a 'type mismatch' error on the last line of this code?
I'm using Access 2000.

Dim myDB As Database, myTB As TableDef
Dim myFD As Field
Set myDB = DBEngine(0)(0)
Set myTB = myDB.TableDefs("scores")
' scores is the name of the table I want to add a field to
Set myFD = myTB.createfield("new_field")
 
I should add that I have DAO 3.6 checked in references, and Access does recognise the 'CreateField' method, but as soon as I move the cursor to the next line, it reverts to the all-lower-case 'createfield', as if it's decided it doesn't like it after all.

Also, I apologise for forgetting to give this thread a proper title. I am aware of it!

Rob
 

With myTB
' The CreateField method will set a default Size
' for a new Field object if one is not specified.
.Fields.Append .CreateField("TextField", dbText)
.Fields.Append .CreateField("IntegerField", dbInteger)
.Fields.Append .CreateField("DateField", dbDate)
End With

PaulF
 
You've done it again! That's another issue resolved straight away. Thank you very much.


Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top