Others

Create Access SQL Server Job Numbers Without Unused IDs

Ayan MasoodAyan Masood Nov 25, 2026 868 views

Question details

Create job numbers for an Access application backed by SQL Server without allocating numbers when users cancel a form.

Create Access SQL Server Job Numbers Without Unused IDs
Product
Microsoft Access and SQL Server
Device & OS
not provided
Scenario
An Access form uses data from a crosstab query after migration to SQL Server, and its job number is derived from an ID.
Observed behavior
An AutoNumber or identity value may not be available when the form opens, while generating a number before confirmation can leave it unused if the user cancels.
Before you start

Identify the table that stores jobs, the components of the job number, and whether numbering is global or separate for each job type. Check that you can modify the SQL Server database and the Access form's save or confirmation action.

Solution 1Recommended

Assign the job number in a SQL Server transaction

Use a table-based counter and allocate a number only when the user confirms the job.

Keep the crosstab for display if needed, but submit the underlying job data through an editable form or a separate save action. Do not allocate the job number when the form opens.

The counter update and job insert must occur in the same SQL Server transaction so a failed insert rolls back the allocation. Avoid DMax for multiuser number generation because concurrent users can retrieve the same maximum value.

1
Create a counter table

In SQL Server Management Studio, create a counter table with a key for each numbering series, such as job type, and a column holding its last assigned number. Initialize each series before users submit jobs.

2
Create a save procedure

In SQL Server Management Studio, create a stored procedure that starts a transaction, locks and increments the appropriate counter row, inserts the job using that number, and commits. Add error handling that rolls back the transaction if the operation fails.

3
Submit from the Access form

In the Access form's confirmation button On Click event, validate the entered values and call the stored procedure with the job details. Retrieve the assigned number from the procedure and display it after the save succeeds.

4
Test cancellation and concurrency

Open the form and cancel before confirming; verify that the counter has not changed. Then submit jobs from two sessions and check the job table for distinct, consecutive committed numbers.

Assign the job number in a SQL Server transaction
Limits of gap-free numbering: A rolled-back allocation can be reused, but deleting a committed job or canceling it after confirmation can still leave a visible gap. Retain committed jobs with a canceled status if the business requires an auditable sequence.
Free Microsoft Office alternative

Review Exported Job Data with WPS Office

WPS Office is a free, lightweight Office alternative with a familiar interface. Open exported job data in WPS Spreadsheets for an easy transition between Office files; it does not replace the Access and SQL Server transaction needed to assign job numbers.

Review and filter exported job numbers in WPS SpreadsheetsCompatible with Microsoft Excel formats, including XLSX and XLSFamiliar spreadsheet interface for working with existing Office filesFree and lightweight for everyday document and spreadsheet work
microsoft office alternative - wps office

Frequently Asked Questions

Why shouldn't I generate the job number when the form opens?

If the user closes or cancels the form, a number allocated at opening may never be used. Generate it in the confirmation or save action instead.

Can I use DMax to find the next job number?

DMax is risky in a multiuser application because two users can read the same maximum before either saves. Use a SQL Server counter table and transaction to serialize allocations.

Will a SQL Server identity column guarantee consecutive job numbers?

No. Identity values can have gaps, including after failed or rolled-back inserts. Use a transactional counter if the business requires consecutive numbers for committed jobs.

What if my Access crosstab form is not editable?

Keep the crosstab for display and enter job details on a separate form. Call a SQL Server save procedure from the form's confirmation button, then requery the display.

What happens if a job is canceled after it has been saved?

Its committed number has already been assigned. Keep the job record and mark it canceled if you need to preserve an auditable sequence rather than deleting it.