VBA in On Click Event Mystery

G

Guest

When the On Click event executes the following code from a form with
Me![SignSel1] <> Cancel MS Access shuts down. If I put a break point in the
code and step through it executes fine.

OS: Win2K for NT
Access Version: Access 97
Ram: 128 Mb

The following is the code in the On Click event on the form:
Private Sub SignSel1_Click()
If Me![SignSel1] = "Cancel" Then
Me![Action] = Null
Me![SignSrc1] = ""
Me![SignDt1] = Null
Me![ActCompDt1] = Null
MsgBox "Cancelling does not reset the Project Status - please ensure
status is reset in Project Master to original value."
If (Forms![Active Release Log Update]![StatCd1] = "Prod") And
(Forms![Active Release Log Update]![Status] = "Prod") Then
Forms![Active Release Log Update]![Status Date] = Date
Forms![Active Release Log Update]![Status] = "QA"
DoCmd.OpenForm ("Audit Table"), acNormal, , , acFormAdd, acHidden
Forms![Audit Table]![Audit Source] = [CurrentUser]
Forms![Audit Table]![Audit Field] = "Status Reset"
Forms![Audit Table]![Audit New Value] = Forms![Active Release
Log Update]![Status]
Forms![Audit Table]![Audit Project Number] = Me![Project Number]
DoCmd.Close acForm, "Audit Table", acSaveNo
GoTo BypassSO:
Else
GoTo BypassSO:
End If
End If

If (Forms![Active Release Log Update]![Status] = "QDen") Or
(Forms![Active Release Log Update]![Status] = "TDen") Then
MsgBox "You may not approve a project in denied status, please reset
the Denial button and then retry"
GoTo BypassSO:
End If
If (Forms![Active Release Log]![DepNotOK] = "NO") And (Forms![Active
Release Log Update]![Status] = "TOG") Then
MsgBox "You may not approve a project when it contains subordinate
projects that have not been approved"
GoTo BypassSO:
End If

If (Forms![Active Release Log]![OpenTkt] > "") Then
DoCmd.OpenForm "Active Release Log OpenTkt Popup", acNormal
GoTo BypassSO:
End If

If Me![SignSrc1] > "" Then
Me![SignSrc1] = Me![SignSrc1] & ", " & Me![Resource1] & "(" & Date &
"/" & [CurrentUser] & ")"
Else
Me![SignSrc1] = Me![Resource1] & "(" & Date & "/" & [CurrentUser] &
")"
End If
Me![SignDt1] = Date
DoCmd.OpenForm ("Audit Table"), acNormal, , , acFormAdd, acHidden
Forms![Audit Table]![Audit Source] = [CurrentUser]
Forms![Audit Table]![Audit Field] = "SignoffSel"
Forms![Audit Table]![Audit New Value] = Me![SignSrc1] & " for " &
Me![StatCd1]
Forms![Audit Table]![Audit Project Number] = Me![Project Number]
DoCmd.Close acForm, "Audit Table", acSaveNo

If Me![ActCompDt1] > "" Then
GoTo BypassSO:
End If
If (Forms![Active Release Log Update]![StatCd1] = "Prod") And
(Forms![Active Release Log Update]![OKtoProd] <> "Yes") Then
If Me![Release Key] Like "*-n*" Then
GoTo BypassSO:
Else
Me![Action] = "SATApp"
GoTo BypassSO:
End If
Else
Me![ActCompDt1] = Me![SignDt1]
End If
DoCmd.OpenForm ("Audit Table"), acNormal, , , acFormAdd, acHidden
Forms![Audit Table]![Audit Source] = [CurrentUser]
Forms![Audit Table]![Audit Field] = "Act Comp Dt"
Forms![Audit Table]![Audit New Value] = Me![ActCompDt1] & " for " &
Me![StatCd1]
Forms![Audit Table]![Audit Project Number] = Me![Project Number]
DoCmd.Close acForm, "Audit Table", acSaveYes
If (Forms![Active Release Log Update]![Status] = "TOG") And
(Forms![Active Release Log Update]![StatCd1] = "TOG") Then
Forms![Active Release Log Update]![Status Date] = Me![ActCompDt1]
Forms![Active Release Log Update]![Status] = "QA"
DoCmd.Save
If (Me![Release Key] Like "*-Q*") Then
Me![Action] = "ToQA"
End If
ElseIf (Forms![Active Release Log Update]![Status] = "QA") And
(Forms![Active Release Log Update]![StatCd1] = "Prod") Then
Forms![Active Release Log Update]![Status Date] = Me![ActCompDt1]
Forms![Active Release Log Update]![Status] = "Prod"
DoCmd.Save
If (Me![Release Key] Like "#.#*") Then
Else
Me![Action] = "ToProd"
End If
End If
BypassSO:
End Sub
 
G

Graeme Richardson

Hi, in such cases I try inserting a DoEvents statement or two.

Try placing DoEvents at start of procedure and run code. If this cures crash
then leave it.

Place breakpoints throughout the procedure. Start with last If clause and
work back until code doesn't crash. Then insert break on statements in If
statement until you establish the line of code that causes crash.
Examine the problem statement. If no problem with statement them place
DoEvents before it.

HTH, Graeme.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top