Avatar of Jass Saini
Jass Saini

asked on 

When I delete one Remark in one record ..it deletes all

I have a code that writes the same Remark to all the records that have a value in BC1.  Bu when I delete one Remark, it deletes all the remark in the rest of the records that have a value in BC1.  

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

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

End Sub

Open in new window


Not sure which line is doing this.  I have this code as an After Update event
Microsoft Access

Avatar of undefined
Last Comment
Gustav Brock
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

It is this line:

         rst![Remarks1] = Null

Comment it out if you don't want this.

/gustav
Avatar of PatHartman
PatHartman
Flag of United States of America image

You are not selecting a specific record you want to update.  You are looping through the whole table and deleting all values.
Avatar of Jass Saini
Jass Saini

ASKER

Hello Gustav,

I tried to comment that line out and still if I comment out and delete.  It deletes all the Remarks1 "Input" in all the records

Pat--I want it to loop through when I am making a input into the Remarks1 field to copy the comment to all the records.  But if I delete a comment from the Remarks1 field ...I just want to be able to delete just that one.
ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Jass Saini
Jass Saini

ASKER

Thank You that worked
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

You are welcome!

/gustav
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo