I am trying to create a rather unusual custom counter. Any ideas will be greatly appreciated.
I have already tried ideas based on the Microsoft Article 210194 (Formerly (Q210194) and I can't get it to work.
The process is this:
1. Someone creates a record that is essentially details of a project. A project code and a component code are manually entered, e.g. '123' and 'A'.
2. During the course of time someone else comes along and records component changes in the database. They retrieve the record for the project and in a subform (the many end of a 1-M relationship) they record component changes.
This is where the custom counter is raised, (when component changes are added). The format of the custom counter is project code and component code, a hyphen and a count of the previous comonent changes +1, e.g. 123A-1, 123A-2, etc. It is the count that I am having difficulty with.
I have found that when two people are simultaneously trying to raise different changes on the same project and component at the same time the count duplicates, e.g. 123A-3 and 123A-3. I cannot stop this from happening.
As stated already I have adapted the technique suggested in article 210194 to no avail and here is my latest attempt. I am trying to lock the table where the change is recorded rather than trying to lock a counter table:
Dim rs As ADODB.Recordset
Dim NextCounter As Double
Set rs = New ADODB.Recordset
rs.Open "tblChanges", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
NextCounter = DCount("[ChangeID]", "tblChanges", _
"[ProjectCode]&[ChangeCode=" & "'" & Me.[FindBox] & "'")
Forms![frmProject]![subfrmChanges].Form![CustomCounter].Value _
= Me.ProjectCode & "-" & Me.BoardCode & NextCounter + 1
DoCmd.RunCommand acCmdSaveRecord
rs.Close
I have already tried ideas based on the Microsoft Article 210194 (Formerly (Q210194) and I can't get it to work.
The process is this:
1. Someone creates a record that is essentially details of a project. A project code and a component code are manually entered, e.g. '123' and 'A'.
2. During the course of time someone else comes along and records component changes in the database. They retrieve the record for the project and in a subform (the many end of a 1-M relationship) they record component changes.
This is where the custom counter is raised, (when component changes are added). The format of the custom counter is project code and component code, a hyphen and a count of the previous comonent changes +1, e.g. 123A-1, 123A-2, etc. It is the count that I am having difficulty with.
I have found that when two people are simultaneously trying to raise different changes on the same project and component at the same time the count duplicates, e.g. 123A-3 and 123A-3. I cannot stop this from happening.
As stated already I have adapted the technique suggested in article 210194 to no avail and here is my latest attempt. I am trying to lock the table where the change is recorded rather than trying to lock a counter table:
Dim rs As ADODB.Recordset
Dim NextCounter As Double
Set rs = New ADODB.Recordset
rs.Open "tblChanges", CurrentProject.Connection, adOpenKeyset, adLockOptimistic
NextCounter = DCount("[ChangeID]", "tblChanges", _
"[ProjectCode]&[ChangeCode=" & "'" & Me.[FindBox] & "'")
Forms![frmProject]![subfrmChanges].Form![CustomCounter].Value _
= Me.ProjectCode & "-" & Me.BoardCode & NextCounter + 1
DoCmd.RunCommand acCmdSaveRecord
rs.Close