Liveson-

Is this form bound to StaffDetails and is it possibly "dirty" when you do
this?  If so, you should make sure the record is saved first:

  If Me.Dirty Then Me.Dirty = False

Also, RunSQL is not the best way to go.  Use:

  CurrentDb.Execute stSQL, dbFailOnError

John Viescas, author
Building Microsoft Access Applications
Microsoft Office Access 2003 Inside Out
Running Microsoft Access 2000
SQL Queries for Mere Mortals
http://www.viescas.com/
(Paris, France)
For the inside scoop on Access 2007, see:
http://blogs.msdn.com/access/


-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of Tumbulu
Sent: Friday, May 19, 2006 3:05 PM
To: [email protected]
Subject: [ms_access] WRITE CONFLICT ERROR
Importance: High


Hi All

I've a problem. I'm trying to develop a human resource management system for
our company. The project is almost complete now and I'm just applying some
final touches.

In the system, I don't want an employee to be completely deleted from the
system when they resign, retire, die or are dismissed . What I want is just
to mark them as deleted. Here is part of the code I'm using

Sub DeleteEmployee()
On Error GoTo Err_cmdDeleteEmployee
Dim stCriteria As String, stSQL As String, stFullName As String
Dim stConfirmDelete As String, stReason As String

stFullName = FirstName & " " & Surname
stReason = DLookup("DeleteReason", "DeleteReasons", "ID = " &
Me.DeleteReason)
stConfirmDelete = "Are you sure you want to delete " & stFullName & " and
the reason is " & Chr(10) & Chr(13)
stConfirmDelete = stConfirmDelete & stReason
stCriteria = "StaffDetails.EmpID = '" & Me.EmpID & "'"
If MsgBox(stConfirmDelete, vbCritical + vbYesNo + vbDefaultButton2,
GetCompany) = vbYes Then
    stSQL = "UPDATE StaffDetails SET StaffDetails.Deleted = -1 WHERE " &
stCriteria & ";"
    DoCmd.RunSQL stSQL
Else
    stSQL = "UPDATE StaffDetails SET StaffDetails.DeleteReason = " & Chr(34)
& Chr(34) & " WHERE " & stCriteria & ";"
    DoCmd.RunSQL stSQL
End If
Me.Refresh

...

Now the problem is that when I confirm Delete by clicking on Yes Access
tells me that another user has changed the record since I started editing it
and that if I save the record I'll overwrite the changes made by the other
user. I'm then given 3 choices: Save Record, Copy to Clipboard and Drop
Changes. If I select Save Record, the field Deleted is not updated to True.
I'm completely stuck. At one point it did work as expected but thereafter
nope. It is installed on my pc only.

Any assistance will be highly appreciated.

Regards

Liveson






Please zip all files prior to uploading to Files section.
Yahoo! Groups Links













Yahoo! Groups Links











SPONSORED LINKS
Microsoft access database Database development software Database management software
Database software Inventory database software Membership database software


YAHOO! GROUPS LINKS




Reply via email to