Updating record makes a copy of record?

hugparty

Registered User.
Local time
Today, 14:54
Joined
Mar 17, 2009
Messages
21
I have a form with a drop down box that populates when you select one of the values from the drop down.

I would like users to be able to select an account from the drop down, edit the associated name info, click "Update" and have that record updated.

Currently it does update the record, but it also creates a duplicate record. What could be causing this?

Here is the code behind the Update button:
Private Sub UpdateRecord_Click()
On Error GoTo Err_UpdateRecord_Click

DoCmd.RunCommand acCmdSaveRecord
DoCmd.GoToRecord , , acNewRec
Exit_UpdateRecord_Click:
Exit Sub

Err_UpdateRecord_Click:
MsgBox Err.Description
Resume Exit_UpdateRecord_Click

End Sub

Alice
 
Code:
DoCmd.GoToRecord , , acNewRec
The above line goes to a new record after the current record has been saved.

Are you want to go to a New record?
 
And do you have any OTHER code on your form or controls?
 
Yes. I just don't want it to duplicate the updated record into a new, duplicate record.
 
And do you have any OTHER code on your form or controls?

Yes. Here you go...



Private Sub Combo21_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[HIC_CLAIM_NUMBER] = '" & Me![Combo21] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
End Sub


Private Sub AddRecord_Click()
On Error GoTo Err_AddRecord_Click


DoCmd.RunCommand acCmdSaveRecord
DoCmd.GoToRecord , , acNewRec
Exit_AddRecord_Click:
Exit Sub

Err_AddRecord_Click:
MsgBox Err.Description
Resume Exit_AddRecord_Click

End Sub
Private Sub UpdateRecord_Click()
On Error GoTo Err_UpdateRecord_Click

DoCmd.RunCommand acCmdSaveRecord
DoCmd.GoToRecord , , acNextRec
Exit_UpdateRecord_Click:
Exit Sub

Err_UpdateRecord_Click:
MsgBox Err.Description
Resume Exit_UpdateRecord_Click

End Sub
Private Sub DeleteRecord_Click()
On Error GoTo Err_DeleteRecord_Click


DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord

Exit_DeleteRecord_Click:
Exit Sub

Err_DeleteRecord_Click:
MsgBox Err.Description
Resume Exit_DeleteRecord_Click

End Sub
 
Try replacing:
Code:
DoCmd.RunCommand acCmdSaveRecord
DoCmd.GoToRecord , , acNewRec
...with:
Code:
Me.Refresh
 
Try replacing:
Code:
DoCmd.RunCommand acCmdSaveRecord
DoCmd.GoToRecord , , acNewRec
...with:
Code:
Me.Refresh


THANK YOU! I love this board. Maybe one day I'll learn enough to help people too!
 
I think this is related... I need for 1 of the drop down box selections (ex client) to save the record to a different (ex clients) table, and delete the record in the current (live clients) table. This sounds easy, but I'm having a bit of trouble. Can you suggest the words to use?
 

Users who are viewing this thread

Back
Top Bottom