Others

Fix Microsoft Access Error 6 Overflow When an AutoNumber Exceeds 32767

Kushani NimanthikaKushani Nimanthika Nov 13, 2026 869 views

Question details

The user needs to resolve Microsoft Access run-time error 6 Overflow when a ParticipantServiceID AutoNumber reaches 32768, but VBA variables or parameters still use the Integer data type.

Fix Microsoft Access Error 6 Overflow When an AutoNumber Exceeds 32767
Product
Microsoft Access VBA
Device & OS
not provided
Scenario
A ParticipantServiceID AutoNumber field exceeds the VBA Integer limit of 32,767 and is passed to a VBA function.
Observed behavior
Access displays run-time error 6: Overflow because VBA declares the ID parameters and variables as Integer and uses CInt instead of CLng.
Before you start

Open the Microsoft Access VBA editor and search for LookUpAlreadyExists, ParticipantServiceID, IncidentID, CInt, and related Integer declarations. Confirm that the AutoNumber field is intended to grow beyond 32,767 before changing the data types.

Solution 1Recommended

Change All Related VBA ID Parameters and Variables from Integer to Long and Replace CInt with CLng

Use this solution when ParticipantServiceID reaches 32768 or higher and Access raises run-time error 6 because the value exceeds the VBA Integer limit.

VBA Integer variables can only store values up to 32,767. Access AutoNumber fields commonly continue beyond that limit, so all related ID variables and parameters must use Long, and CInt conversions must be replaced with CLng.

1
Open the VBA editor and find the affected code

In Microsoft Access, press Alt+F11 to open the VBA editor, then press Ctrl+F and search for LookUpAlreadyExists, ParticipantServiceID, and CInt.

2
Change function declarations from Integer to Long

Change every related ID parameter in the function declarations from Integer to Long. For example, change Function LookUpAlreadyExists(ByVal ParticipantID As Integer, ByVal IncidentID As Integer) As Boolean to Function LookUpAlreadyExists(ByVal ParticipantID As Long, ByVal IncidentID As Long) As Boolean.

3
Replace CInt with CLng for AutoNumber values

Find CInt(Me.ParticipantServiceID.Value) and replace it with CLng(Me.ParticipantServiceID.Value) so the AutoNumber value is handled as a 32-bit Long instead of a 16-bit Integer.

4
Compile and save the VBA project

In the VBA editor, click Debug, select Compile VBA Project, save the module, and then rerun the form or process that previously produced the overflow error.

Change All Related VBA ID Parameters and Variables from Integer to Long and Replace CInt with CLng
Overflow resolved: The error should no longer appear when ParticipantServiceID is 32768 or higher, as long as all related variables and parameters are declared as Long.
Free Microsoft Office alternative

Need a Lightweight Office Suite Without Access VBA Overflow Issues?

WPS Office is a free, lightweight Microsoft Office alternative that handles everyday Word, Excel, and PowerPoint files without the cost or complexity of Access VBA. It keeps familiar formatting and makes it easy to open, edit, and save common Office documents.

Avoid Access-only VBA overflow debugging by managing data in WPS Spreadsheets with familiar Excel-compatible formulasFull compatibility with .xlsx, .xls, .docx, .pptx, and other Microsoft Office formatsFree, lightweight suite with a familiar ribbon interface and easy migrationNo Microsoft Access license required for common list, lookup, and reporting tasksAvailable on Windows, macOS, Linux, Android, and iOS
microsoft office alternative - wps office

Frequently Asked Questions

Why does Access show run-time error 6 when an AutoNumber reaches 32768?

Access shows run-time error 6 because the VBA code is storing or passing the value as an Integer. VBA Integer has a maximum value of 32,767, so an AutoNumber value of 32768 overflows it. The related variable or parameter must be declared as Long.

Which VBA declarations need to change from Integer to Long?

Change every related ID parameter and variable from Integer to Long. This includes the LookUpAlreadyExists and LookUpAlreadyExists2 function declarations, especially parameters such as ParticipantID and IncidentID.

Should I replace CInt with CLng for AutoNumber values?

Yes. Replace CInt(Me.ParticipantServiceID.Value) with CLng(Me.ParticipantServiceID.Value). CLng converts the value to a Long, which can hold AutoNumber values above 32,767.

Are large, nonsequential AutoNumber values a sign of data corruption?

No. AutoNumber fields are not sequential counters. Gaps and nonsequential values are normal and do not indicate a problem with the database.

Does WPS Office include a Microsoft Access replacement?

WPS Office does not include an Access equivalent. For spreadsheet-based data, WPS Spreadsheets can open and save Excel-compatible files and offers a free alternative for many common list, lookup, and reporting tasks.