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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

NEW record - Using DMax

Status
Not open for further replies.

darinmc

Technical User
Feb 27, 2005
171
GB
Hi
I am already using this code to create a new record. This works fine BUT if 2 people try create a record at the same time, an error occurs as the EmpRegNo is the same...

Code:
Private Sub cmdNewRec_Click()
Dim VarEmpReg As Integer
VarEmpReg = Nz(DMax("[EmpRegNo]", "tblEmployee")) + 1
DoCmd.GoToRecord , , acNewRec
Me.EmpRegNo = VarEmpReg
Me.EmpRegDate.SetFocus
Forms!frmEmpRead!EmpMemoChanges = "NEW EMPLOYEE STARTED BY - " & Forms!frmSwitchboard!tName & " - " & Now()
End Sub

How would i check if record is in the EDIt state OR how do I work round this???

Thx
Darin
 
I keep the "next" number in a separate table. When I need to assign it to a new record, I grab it and then immediately update the "next" number.

The referenced FAQ does basically the same except takes it one step further by locking the record until the update is complete.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top