[Webinar] Streamline your web hosting managementRegister Today

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 461
  • Last Modified:

Error in Access: Too many fields defined

After installing my application in offices, "run time error '3190' - Too many fields defined" occurs when I tried to create an addtional field in one of my tables in MS Access at run time. I clicked on Help button and it says I exceeded the 255 field limit. My table has only 15 fields and an average of 10,000 records.

Private Sub Text8_KeyPress(KeyAscii As Integer)
Dim ws As Workspace
Dim db As Database
Dim CheckTicket, TempRec As Recordset
Dim td As TableDef
Dim fld As Field

    Select Case KeyAscii
        Case vbKeyReturn, vbKeyTab
            StatusBar1.Panels(1).Text = "Please wait..."
            Set ws = DBEngine.Workspaces(0)
            Set db = ws.OpenDatabase("c:\btfb\btfb.mdb")
            Set td = db.TableDefs("trnxfile")
            Set fld = td.CreateField("temp", dbInteger)
            td.Fields.Append fld <-The error occurs here

  • 2
1 Solution
   Do you get the error message the very first time or after a fewtimes the keypress event is fired?.
on the second keypress, you are attempting to add a second field called TEMP.... You can't name a field the same thing twice!
Instead of
 Dim fld as Field
 Dim fld as new field
& see to it that the field duplication does not occur.

or try the following:

private sub Text8_KeyPress(KeyAscii As Integer)
   Dim Ws As Workspace
   Dim Db as Database

   Set Ws = DBEngine.Workspaces(0)
   Set Db = Ws.OpenDatabase(App.path & "\dtfb.MDB")

AdNewField Db, "Purchase","PRate",DbLong

End Sub

Public Sub AdNewField(dbsDB as Database, TableName As String, FieldName As String, FieldType As Integer, Optional FieldSize As Integer, Optional ZeroLength, Optional Required, Optional Attributes)
   Dim fldField as New Field
   fldField.Name = FieldName
   fldField.Type = FieldType

   If Not IsMissing(FieldSize) Then fldField.Size = FieldSize
   If Not IsMissing(ZeroLength) Then fldField.AllowZeroLength = ZeroLength
   If Not IsMissing(Required) Then fldField.Required = Required
   If Not IsMissing(Attributes) Then fldField.Attributes = Attributes
   dbsDB.TableDefs(TableName).Fields.Append fldField

End Sub

To add a field in a database, I dont think the keypress event is a right event. Why dont you try some click event?


Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now