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!

Write conflict error when updating table through form 1

Status
Not open for further replies.

samyers

Technical User
Mar 15, 2007
15
US
I have a table which users need to update via a form. There is a combo box which they use to select the record to update. The box has this code behind it:

Private Sub cmbGroup_AfterUpdate()
strGrpNumber = "SELECT * FROM tblGroups " _
& " WHERE GrpNumber = '" _
& Me!cmbGroup.Column(0) & "'"
Me.RecordSource = strGrpNumber
Me.Refresh
End Sub

This works fine and populates all the fields on the form.

When the user clicks the 'Save Changes' button, this code is executed:
Private Sub cmdSaveRecord_Click()
On Error GoTo SaveRecordError

strSQL = "UPDATE tblGroups SET tblGroups.GrpName = '" & txtGrpName & _
<update all the other fields on the table with corresponding form field values>
"WHERE tblGroups.GrpNumber = '" & txtGrpNumber & "';"

DoCmd.RunSQL strSQL

Here I get a write conflict. Can someone tell me what I'm doing wrong?
Thanks!
 
You have a write conflict just because you want to update with code the Current record of a bound form ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Y'know, I'm torn between being relieved that I finally got the command right, and irritated that it was so obvious:

DoCmd.RunCommand acCmdSaveRecord

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top