I don't know why, but when I do the following, the ONCURRENT event is run 3 times.
Private Sub Delete_Click()
'On Error GoTo DeleteClick_err
Dim Answer As Integer
Answer = MsgBox("Are you sure you want to delete this ticket?", 4, "Delete Ticket"
DoCmd.SetWarnings False
If Answer = 6 Then
If IsNull(Me.ID) = True Then
MsgBox ("You can't delete an Entry that doesn't exist!"
Exit Sub
End If
fDeleteTicketOffsets (wProofAdj)
DoCmd.RunCommand acCmdDeleteRecord
fRequeryScreen ("BalanceBranch"
End If
DoCmd.SetWarnings True
Exit Sub
DeleteClick_err:
MsgBox ("Deletion of this Entry is not permitted at this time."
Resume Next
End Sub
THE FOLLOWING ARE THE 2 FUNCTIONS CALLED FROM THE SUB ABOVE:
Public Function fDeleteTicketOffsets(DeleteFromScreen As String)
Dim db As DAO.Database
Dim qd As DAO.QueryDef
Dim prm As DAO.Parameter
Dim TicketNumber As Long
MsgBox ("Deleting Tickets..."
Set db = CurrentDb()
With CodeContextObject
TicketNumber = .ListID
'This is for proofadj's that has offset in the 'other' table, and for cash which has MTA tickets
If DLookup("[id]", "[tbDailyOtherTickets]", "[offsettoid] = " & TicketNumber) Then
Set qd = db.QueryDefs("qryDeleteTicketsOtherOffset"
If qd.ReturnsRecords = True Then
qd!deleteid = TicketNumber
qd.Execute
fShadelbls (DeleteFromScreen)
End If
Set qd = Nothing
End If
'This is for Proof tickets joined on a cash Adjustment
If DLookup("[id]", "[tbDailyProofTickets]", "[offsettoid] = " & TicketNumber) Then
Set qd = db.QueryDefs("qryDeleteTicketsProofOffset"
If qd.ReturnsRecords = True Then
qd!deleteid = TicketNumber
qd.Execute
fShadelbls (DeleteFromScreen)
End If
Set qd = Nothing
End If
End With
Set qd = Nothing
Set db = Nothing
End Function
Public Function fRequeryScreen(frmName As String)
'MsgBox ("requery"
'checks to see if the screen is open, if so it requeries the form
If SysCmd(acSysCmdGetObjectState, acForm, frmName) <> 0 Then
If Forms(frmName).CurrentView <> 0 Then
'DoCmd.RunCommand acCmdSaveRecord
Forms(frmName).Requery
End If
End If
End Function
I cant really fathom why the oncurrent is run 3 times, I dont' want it to run 3 times - just once after a delete. I understand the the requery method does trigger the oncurrent, but for the other 2 times the oncurrent event is triggered is a mystery to me. Can anyone explain to me why? I greatly appreciate this.
I want to thank everyone thas has helped me over the past few days, If you follow the posts I've been posting, I haven't had the easiest time with the work I'm currently engaged doing.
You guys are great! I try to post helpful tips when I get a chance.
Randall Vollen
National City Bank Corp.
Just because you have an answer - doesn't mean it's the best answer.
Private Sub Delete_Click()
'On Error GoTo DeleteClick_err
Dim Answer As Integer
Answer = MsgBox("Are you sure you want to delete this ticket?", 4, "Delete Ticket"
DoCmd.SetWarnings False
If Answer = 6 Then
If IsNull(Me.ID) = True Then
MsgBox ("You can't delete an Entry that doesn't exist!"
Exit Sub
End If
fDeleteTicketOffsets (wProofAdj)
DoCmd.RunCommand acCmdDeleteRecord
fRequeryScreen ("BalanceBranch"
End If
DoCmd.SetWarnings True
Exit Sub
DeleteClick_err:
MsgBox ("Deletion of this Entry is not permitted at this time."
Resume Next
End Sub
THE FOLLOWING ARE THE 2 FUNCTIONS CALLED FROM THE SUB ABOVE:
Public Function fDeleteTicketOffsets(DeleteFromScreen As String)
Dim db As DAO.Database
Dim qd As DAO.QueryDef
Dim prm As DAO.Parameter
Dim TicketNumber As Long
MsgBox ("Deleting Tickets..."
Set db = CurrentDb()
With CodeContextObject
TicketNumber = .ListID
'This is for proofadj's that has offset in the 'other' table, and for cash which has MTA tickets
If DLookup("[id]", "[tbDailyOtherTickets]", "[offsettoid] = " & TicketNumber) Then
Set qd = db.QueryDefs("qryDeleteTicketsOtherOffset"
If qd.ReturnsRecords = True Then
qd!deleteid = TicketNumber
qd.Execute
fShadelbls (DeleteFromScreen)
End If
Set qd = Nothing
End If
'This is for Proof tickets joined on a cash Adjustment
If DLookup("[id]", "[tbDailyProofTickets]", "[offsettoid] = " & TicketNumber) Then
Set qd = db.QueryDefs("qryDeleteTicketsProofOffset"
If qd.ReturnsRecords = True Then
qd!deleteid = TicketNumber
qd.Execute
fShadelbls (DeleteFromScreen)
End If
Set qd = Nothing
End If
End With
Set qd = Nothing
Set db = Nothing
End Function
Public Function fRequeryScreen(frmName As String)
'MsgBox ("requery"
'checks to see if the screen is open, if so it requeries the form
If SysCmd(acSysCmdGetObjectState, acForm, frmName) <> 0 Then
If Forms(frmName).CurrentView <> 0 Then
'DoCmd.RunCommand acCmdSaveRecord
Forms(frmName).Requery
End If
End If
End Function
I cant really fathom why the oncurrent is run 3 times, I dont' want it to run 3 times - just once after a delete. I understand the the requery method does trigger the oncurrent, but for the other 2 times the oncurrent event is triggered is a mystery to me. Can anyone explain to me why? I greatly appreciate this.
I want to thank everyone thas has helped me over the past few days, If you follow the posts I've been posting, I haven't had the easiest time with the work I'm currently engaged doing.
You guys are great! I try to post helpful tips when I get a chance.
Randall Vollen
National City Bank Corp.
Just because you have an answer - doesn't mean it's the best answer.