Article ID: 199076
Article Last Modified on 6/23/2005
UPDATE Table SET A=B, C=D
SELECT A,B,C,D
FROM Table
' ****************************************************************
' Declarations section of the module
' ****************************************************************
Option Compare Database
Option Explicit
' ****************************************************************
' The Fill_Table() function creates a table in the current database
' named Field Test with 128 fields, each of which has a Text data
' type and a size of five characters.
' ****************************************************************
Function Fill_Table()
Dim mydb As DAO.Database
Dim tbl As DAO.TableDef
Dim fld As DAO.Field
Dim i As Integer
Set mydb = CurrentDb()
Set tbl = mydb.CreateTableDef("Field Test")
For i = 0 To 127
Set fld = tbl.CreateField("Field" & CStr(i + 1))
fld.Type = DB_TEXT
fld.Size = 5
tbl.Fields.Append fld
Next i
mydb.TableDefs.Append tbl
End Function
' ****************************************************************
' The Fill_Data() function adds one record to the table with
' all fields equal to "Text."
' ****************************************************************
Function Fill_Data()
Dim mydb As DAO.Database
Dim fld As DAO.Field
Dim rs As DAO.Recordset
Dim i As Integer
Set mydb = CurrentDb()
Set rs = mydb.OpenRecordset("Field Test")
rs.AddNew
For i = 0 To rs.Fields.Count - 1
rs.Fields(i).Value = "Text"
Next i
rs.Update
rs.Close
End Function
' ****************************************************************
' The Build_SQL() function creates an update query in the current
' database named Update Test which will update the 128 fields in
' the Field Test table to the letter 'T.'
' ****************************************************************
Function Build_SQL()
Dim mydb As DAO.Database
Dim qdf As DAO.QueryDef
Dim x As String
Dim i As Integer
x = "Update [Field Test] SET "
For i = 0 To 127
x = x + "[Field Test].Field" & CStr(i + 1) & " = 'T', "
Next
x = Left(x, Len(x) - 2)
Set mydb = CurrentDb()
Set qdf = mydb.CreateQueryDef("UpdateTest", x)
End Function
? Fill_Table() ? Fill_Data() ? Build_SQL()
198504 ACC2000: "Too Many Fields Defined" Error Message Saving Table
Additional query words: prb
Keywords: kberrmsg kbprb KB199076