Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Nov 2003
    Location
    London, Gtr London, England
    Posts
    222
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VB Problem (2003 (11.6566.6568) SP2)

    Hi there!

    I recently converted an Access DB from 97 to 2003 for a Gym Club and have sorted out most of the problems that have ensued. When a Gym session for a student is deleted, i.e. the student moves up a class, the session is removed form the sessions table and is subsequently archived into a class history table. The anomaly is this works fine on my PC and also on one of the two PC's at the Gym Club. However, on the other PC the session gets deleted, but doesn't get archived. What seems to happen is the subroutines "Form_AfterDelConfirm" and "Form_Delete" (listed below) get skipped. The problem I have is I can't seem to replicate the problem so as to be able to know whether it needs a rewrite or not. Both of the PC specs at the Gym club are the same, right down to Access and the VB references.

    If anyone can view the listed code below (i hope it's legible enough) and advise I would be most grateful. I can also supply a cut down version of the DB if necessary.

    Cheers,

    Niven

    Private Sub cmdDelete_Click()

    If Not IsNull(Me.sesid.Column(0)) Then
    If MsgBox("Delete This Session ?", vbCritical + vbYesNo, "Delete Session") = vbYes Then
    DoCmd.RunCommand acCmdDeleteRecord
    End If
    End If

    End Sub



    Private Sub Form_AfterDelConfirm(Status As Integer)

    ' if user confirmed the delete
    If Status = 0 Then
    DoCmd.SetWarnings False
    DoCmd.RunSQL strInsert
    MsgBox "Deleted information has been added to the Class History Data", vbOKOnly + vbInformation
    ' end if user confirmed the delete
    End If

    End Sub


    Private Sub Form_Delete(Cancel As Integer)
    strInsert = "INSERT INTO classhistory VALUES(" & [membership no] & ",'" & Me.sesid.Column(0) & "',#" & Format(Me.date, "dd/mmm/yy") & "#,#" & Format(Now(), "dd/mmm/yyyy") & "#)"
    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: VB Problem (2003 (11.6566.6568) SP2)

    Select Tools | Options... in Access on the problem PC.
    Activate the Edit/Find tab.
    Make sure that the check box labeled Confirm Record Changes is ticked.
    If this check box is clear, the BeforeDelConfirm and AfterDelConfirm events do not occur when a record is deleted.
    You can also use code to ensure that this option is set by executing

    Application.SetOption "Confirm Record Changes", True

    when the database is opened.

  3. #3
    3 Star Lounger
    Join Date
    Nov 2003
    Location
    London, Gtr London, England
    Posts
    222
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VB Problem (2003 (11.6566.6568) SP2)

    Hans,

    Sorry to come back so late, but that did the trick thanks. It's always seems to be the simplest problems that are the hardest ones to solve!

    Cheers,

    Niven <img src=/S/bravo.gif border=0 alt=bravo width=16 height=30>

Posting Permissions

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