Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DMax function only increments a certain amount....

Status
Not open for further replies.

ke4peo

Technical User
Nov 18, 2008
3
US
Hey all,

I'm working on a project for my work and running into a small issue. This doesn't seem to have affected the Dmax function in my other database. It works fine there and continues to increment. However, in this new database I'm working on....

I have a function set up to look at the incidentid field in tbl_sup_queue and increment the highest number by 1. I have it set so that on the entry form load it does the following:

Look to tbl_sup_queue
Dmax +1 highest incidentid number
Save record (this is done as is multi-user to prevent duplicate incidentid numbers)

What is happening, is that Dmax is hitting incidentid number 10 and stopping. It will not increment further. I'm pasting the code below if anyone can help me out.

Thanks in advance -

Code:
Private Sub Form_Load()
    Me![incidentid] = NewID()
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
End Sub

Public Function NewID() As Long

On Error GoTo NextID_Err

Dim lngNewID As Long

    lngNewID = DMax("[incidentid]", "tbl_sup_queue") + 1

    'Assign function the value of the Next ID
    NewID = lngNewID

    'Exit function now after successful incrementing or after error message
Exit_NewID:
Exit Function

    'If an error occurred, display a message, then go to Exit statement
NextID_Err:
    MsgBox "Error " & Err & ": " & Error$

    Resume Exit_NewID

End Function
 
Change the datatype of the incidentid field to numeric ;-)

Roy-Vidar
 
Yeah, I just realized that about 15 minutes after I made the post. :p *sheepish grin* Don't know how the field type got changed.

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top