PROBLEM with save button!!!

rsbutterfly16

Registered User.
Local time
Today, 06:41
Joined
Jun 5, 2006
Messages
77
hi guys, i am a working on a form in which is bound to a table in my access database. I have a text box (which its source is the Facility ID, then a combo box that has all the contract id that the facility can have, and then a contract status combo box in which it changes according to the Facility ID and contract id i select...

I have a command button that when the contract status displays active then the user could press and the status will change to "inactive". and then i have the save button... I have the following code in the save button:

Private Sub Command10_Click()

On Error GoTo Err_Command10_Click


If Forms![Status].[cboStatus].Value = Me.cboStatus.OldValue
Then
MsgBox ("Status has not changed")
Cancel = True
Me.cboStatus.Undo

End If


If Me.Dirty Then
DoCmd.RunCommand acCmdSaveRecord
MsgBox "Your New Status is " & cboStatus.Value, vbOKOnly

End If

-----when the status is changed i want these values to be added int the destination table-----------------

Select Case Me!cboStatus
Case "Active", "Inactive"
Me!txtEdit = Now()
Forms![Status-test].[txtOld_value].Value = "Active"
Me!txtEdit_UserName = GetUserName()
Case Else
'No action
End Select


all i am changing is the value in my cboStatus pertaining to that contract id and facility id. not the contract id or the facility id (by the way this is my primary key in the table)

but i press i press the save button i keep getting an error saying:

ODBC failed
[Microsoft.... Violation of Primary Key constraint Facility-PK Cannot insert key in object Facility....


why do i get this error if all i am trying to save is the change that a command button has done to just edit my existing status, all the rest is supposed to stay the same... please help this is driving me nuts...


:confused:
 

Users who are viewing this thread

Back
Top Bottom