Results 1 to 6 of 6
  1. #1
    Join Date
    Feb 2005
    Posts
    333

    Unanswered: Update form after deleting record

    I have a form that is bound to a table. When I programatically delete a record, the form displays #deleted in the field that was deleted. How do I refresh the form so that the user will not see #deleted? This is the code that I am using.

    Code:
    Private Sub txtId_Change()
    On Error GoTo Err_Delete_pk
    
    Dim response As VbMsgBoxResult
    Dim strMessage As String
    
        If Me.txtId.Text = "" Then
            strMessage = "Do you really want to delete this record?"
            response = MsgBox(strMessage, vbYesNo, "Deleting Record")
            
            If response = vbYes Then
                DoCmd.SetWarnings False
                DoCmd.RunSQL ("Delete * from tblActivities where id = " & Me.txtId.Value)
                DoCmd.SetWarnings True
            Else
                Me.Undo
            End If
        End If
        
    Exit_txtId_Change:
        Exit Sub
    
    Err_Delete_pk:
        MsgBox Err.Description
        Resume Exit_txtId_Change
    
    End Sub

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Hi Campster

    Been a while. How about:

    Code:
    Private Sub txtId_Change() On Error GoTo Err_Delete_pk Dim response As VbMsgBoxResult Dim strMessage As String If Me.txtId.Text = "" Then strMessage = "Do you really want to delete this record?" response = MsgBox(strMessage, vbYesNo, "Deleting Record") If response = vbYes Then CurrentDB.Execute "Delete * from tblActivities where id = " & Me.txtId.Value", dbFailOnError Me.Requery Else Me.Undo End If End If Exit_txtId_Change: Exit Sub Err_Delete_pk: MsgBox Err.Description Resume Exit_txtId_Change End Sub
    If you don't like the DAO please at least pop DoCmd.SetWarnings True
    after Exit_txtId_Change: so it gets fired even if there is an error.
    Testimonial:
    pootle flump
    ur codings are working excelent.

  3. #3
    Join Date
    Feb 2005
    Posts
    333
    Been a while.
    Yeah, I've been pretending to write code in VB.Net for awhile.

    I tried Me.Refresh, Me.Requery and Me.Repaint with no luck.

    Edit: Maybe I should mention that this is in A2003
    Last edited by campster; 02-09-06 at 11:30.

  4. #4
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Coo - whats the BE?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  5. #5
    Join Date
    Feb 2005
    Posts
    333
    The entire thing is in A2003. This is a small app that I may not split.

  6. #6
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    What you might try doing is resetting the RecordSource property for the form. That will force a requery.

    Another idea is moving to the next or previous record automatically.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •