We help IT Professionals succeed at work.

Current Record will not update

Jass Saini
Jass Saini asked
on
I have a comment field which is a memo field--I type in the data in into the memo field and I have to update records according to what is typed.  But the current record will not update.


Private Sub Remarks1_AfterUpdate()
 Dim rst As DAO.Recordset
   Dim strRemarks As String
   
    strRemarks = Me.Remarks1
    If strRemarks = "" Then Exit Sub
   
   Set rst = CurrentDb.OpenRecordset("Final_Table")
   'strRemarks = Me.Remarks1

   Do
      rst.Edit
        If Nz(rst![BC1Chng1]) <> "" Then
         rst![Remarks1] = strRemarks
      Else
         rst![Remarks1] = Null
      End If
      rst.Update
      rst.MoveNext

   Loop Until rst.EOF

End Sub

Open in new window

Comment
Watch Question

Scott McDaniel (EE MVE )Infotrakker Software
Most Valuable Expert 2012
Top Expert 2014

Commented:
What do you mean by "current record"? Your code opens a recordset and updates it based on the value in a field on a form (apparently). There is no "current record" except for the record showing on the form, and you're not interacting with the form.

However, if your recordset is based on the same dataset as the form, then you'll not be able to do this. Access won't allow you to update a record that is currently locked on the form, so if you must interact with the same dataset as is on the form, you need to use the Form methods to do this.

But - again - this all goes back to poor design, as we've told you many, many times. Get the design fixed correctly, and you won't have these troubles.

Author

Commented:
Thanks Scott...Love the sarcasm!!
Database Architect / Application Developer
Top Expert 2007
Commented:
Maybe try:

......
Loop Until rst.EOF

Me.Refresh