DB Errors

preethi

Registered User.
Local time
Yesterday, 16:07
Joined
Nov 5, 2007
Messages
30
Hi,

I am updating a simple table directly from the form. I can add or update into the table, but when i close the form i am getting the following messages

Msg1 - "The changes you requested to the table were not successful because they would create duplicate values in the index, primary key or relationship. Change the data in the field or fields that contain duplicate data remove the index or redefine the index to permit duplicate entries and try again"

Msg2 - "Microsoft Access may have encountered an error while trying to save a record. If you close this object now, the data changes made will be lost. Do you want to close the database object anyway?"

Can anyone help me how to hide these messages from the screen?
 
Do you use a unbound form or what do you mean by; "I can add or update into the table"?
 
Hi,

Its a bound form. What i meant is I can add new records to the table and also possible to update data. But i can not see the new records without closing the forms. While closing the forms i am getting the above errors

Hope you got my point
 
What type of form, (single form, data entry or ??), do you use and do you have any code in it?
How do you close the form?
 
Hi,

Its a single form and doing data entry through it. I have considered 2 fields to make primary key and checking the whether we entered value for specific fields. Finally adding into Db using ADODB. recordset functions(rs.Addnew). For updation i am not using any code.
 
This is the code. WHen i select a value in the listbox i need to add it into the table along with other details
Tried to send the file itself ,but cant do it

Private Sub List203_DblClick(Cancel As Integer)
Set rs = New ADODB.Recordset
If Me.Text146.Value <> "" Then
If Me.List203.Value <> "" Then
str = "SELECT * FROM tblSuppression WHERE State_Suppression_ID='" & Me.Text146.Value & "' and Alrm_Tag_No='" & Me.List203.Value & "'"
rs.Open str, cn, adOpenDynamic, adLockOptimistic
If rs.EOF Then
rs.AddNew
rs!State_Suppression_ID = Me.Text146.Value
rs!Alrm_Tag_No = Me.List203.Value
rs!State_Suppression_Desc = Me.Text155.Value
rs!ALM_PT_HH = Me.Text157.Value
rs!Service = Me.Text99.Value
rs.Update
rs.Close
MsgBox "New Tag Number " & Me.List203.Value & " added with Supression ID " & Me.Text146.Value
Else
MsgBox "Tag Number " & Me.List203.Value & " is already existing with Supression ID " & Me.Text146.Value
End If
End If
Else
MsgBox "Please Enter value for Suppression ID"
End If
Me.Item.Value = Me.List203.Value
End Sub
 
This is the code. WHen i select a value in the listbox i need to add it into the table along with other details
Tried to send the file itself ,but cant do it
If you replay to a thread, scroll a little down (about 5cm), then you'll see a button "Mamage Attachments", click it and you can add a file.
Why do you use a recordset, normally a bound form with bound controls, save the input automatic?
So if the control(s) containing the primary key is bound, and you add the same primary key using the recordset, then you get the error.
 

Users who are viewing this thread

Back
Top Bottom