Article ID: 165827
Article Last Modified on 7/16/2002
-or-
'-------------------------------------------------------------------
' UT_ComputeLocksNeeded
'
' Computes the number of SQL Server locks needed to upsize a given
' table. The formula used is:
'
' r / (p \ s)
'
' where:
' s = max record size (we don't average text fields)
' p = SQL Server page size less overhead
' r = number of records in the table
'-------------------------------------------------------------------
Function UT_ComputeLocksNeeded(tdf As TableDef) As Long
On Error GoTo Error_out ' Add this line.
Dim fld As Field
Dim lngRecSize As Long
Dim intBytesPerPage As Integer
' Get record size.
For Each fld In tdf.Fields
lngRecSize = lngRecSize + fld.Size
Next
' Get bytes available per page.
intBytesPerPage = UT_SQL_PAGE_SIZE - UT_SQL_PAGE_OVERHEAD
' Compute number of pages, and thus locks, needed.
UT_ComputeLocksNeeded = tdf.RecordCount / (intBytesPerPage \ _
lngRecSize)
Exit Function ' Add this line.
Error_out: ' Add this line.
UT_ComputeLocksNeeded = 0 ' Add this line.
End Function
Function MakeUpsizeTable()
Dim db As Database
Dim td As TableDef
Dim fd As Field
Dim i As Integer
Set db = CurrentDb
Set td = db.CreateTableDef("tblUpsizeTable")
For i = 1 to 100
Set fd = td.CreateField("Field" & i, dbText, 50)
td.Fields.Append fd
Next i
db.TableDefs.Append td
RefreshDatabaseWindow
Msgbox "Table Created."
End Function
?MakeUpsizeTable
279454 ACC97: "Overflow" Error Message When You Try to Upsize to SQL Server 2000
Additional query words: uw divide
Keywords: kberrmsg kbother kbprb KB165827