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!
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!