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!

MS Access write confict

Status
Not open for further replies.

cleoptra

Programmer
Jan 11, 2004
3
PT
Hi everybody!!
It seems that i'm not the only one with this problem and searching troughout the posts i coludn't find a valid solution, so please anybody help me.

I'm working with an ADP(MS Access Project) connected to an SQLServer DB.When trying to insert a new record in a table, i get the write conflict error, saying that another user has made changes to the record and ansking me to save my changes to the clipboard. I'm the only one tha's using the DB, and i'm a bit confuse about this error.I'm using a form to insert the data and i placed the following code in the before insert envent:

Private Sub Form_BeforeInsert(Cancel As Integer)
Const id As String = "Market"
Dim idrst As ADODB.Recordset
Dim value As Integer


value = Ap236Util.getIdMaxValue(id, idrst)
idrst.Close
Set idrst = Nothing
Me!ID_Market = value + 1

End Sub

The form is based on a query with multiple tables so the UniqueTable propertie is set, so i can insert in only one of them(Market).In the code i'm setting the value of the ID_Market witch is the primary key of the table.The other fiels are filled in the form.

If someone know the way around this problem,please help me because i'm stuck with a very important project and i'm running out of time!

tanks in advance
 
Can you show the code in this function.

Ap236Util.getIdMaxValue(id, idrst)
 
Hi!First of all,tanks for concerning. The function access an IDs table were im keeping the values of all Entities primary keys. This is a strange solution,but it's the way we have to do it. Anyway i don't think that's the problem.
HEre is the code:
Public Function getIdMaxValue(string_id As String) As Integer
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.Open "Select * from IDs", CurrentProject.Connection, _
adOpenKeyset, adLockOptimistic
getIdMaxValue = rst.Fields.Item(string_id).value
rst.Close
Set rst = Nothing
End Function

The new record is actualy inserted in the table and the error ocurre when the refresh is done, i guess.
Maybe if there was an event before refresh, i could catch the error,but there isnt't,i supose.

Again, tanks for any help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top