error number 20

G

Guest

when i run this on my form i get the following: "An unanticipated error has
occurred. The error number is 20 and the description is 'Resume without
error'. Please contact your System
Administrator"

this code is meant to be used on the same form; the form can be accessed
from w/in a 'Baseline', 'Treatments' or 'Follow Up' switchboard page.

i want the user to be forced to enter both the patient number AND cycle
number from the main s'board page. also, when the inappropriate value of the
cycle number (given the switchboard page the form's being opened from) is
entered in the main s'board page, i want the user to be prompted to enter the
correct one.

can you see where the fatal flaw in my logic lies here?

Private Sub Form_Open(Cancel As Integer)
On Error GoTo Error_Handler

' using "ApplyFilter" and "Ted" search string on MS discussion groups
(3/16/2005)'

If IsNull(Forms![Command and Control Center]!SelectPatient) _
Or IsNull(Forms![Command and Control Center]!SelectCycle) Then
' No Patient ID or Cycle entered on main form
MsgBox "Please select a Patient Number and/or Cycle from " _
& "the list provided before continuing." _
, vbInformation, "Which Patient/Cycle?"
' Stop the form from opening
Cancel = True
Resume ExitPoint
End If

Select Case Forms![Command and Control Center]![SwitchboardID]
' this is the Baseline case
Case 2

If [Forms]![Command and Control Center]![SelectCycle] <> 0 Then
MsgBox "You need to enter a Cycle of 0 to access this form"
Cancel = True
End If

' this is the Treatment Case

Case 21
If [Forms]![Command and Control Center]![SelectCycle] <= 1 Or _
[Forms]![Command and Control Center]![SelectCycle] >= 99 Then
MsgBox "You need to enter a Cycle between 1 and 100 to access this form"
Cancel = True
End If

' this is the Follow Up Case

Case 22

If [Forms]![Command and Control Center]![SelectCycle] < 100 Then
MsgBox "You need to enter a Cycle greater of at least 100 to access
this form"
Cancel = True
End If

Case Else

MsgBox "Nothing here just ignore - we should never get to this
switchboard page"

End Select

' Check to see if Final Answer has been entered
If DLookup("FinalAnswer", "tblDefaults") = False Then
' Missing information
MsgBox "The correct Protocol ID and Title have not " _
& "been entered into the database." & vbNewLine _
& "Notify the Administrator. At this time you can " _
& "not enter data into the database.", 64 _
, "Warning -- Read Before Proceeding!"
' Stop the form from opening
Cancel = True
Else
' All clear, continue with form opening
' Patient ID was selected on main form
' Run Security Code
LAS_EnableSecurity Me
' Maximize the form
DoCmd.Maximize
' Apply a filter to match chosen Patient Number and set Cycle to 0
' the basline case
If [Forms]![Command and Control Center]![SwitchboardID] = 2 Then
DoCmd.ApplyFilter , "[Patient Number] = " & _
[Forms]![Command and Control Center]![SelectPatient] & " And
[Cycle] = 0"
' the treatment (21) or follow up (24) case
ElseIf [Forms]![Command and Control Center]![SwitchboardID] = 21 _
Or [Forms]![Command and Control Center]![SwitchboardID] = 24 Then
DoCmd.ApplyFilter , "[Patient Number] = " & _
[Forms]![Command and Control Center]![SelectPatient] & _
" And [Cycle] = " & [Forms]![Command and Control
Center]![SelectCycle]
End If
' Fill in Protocol ID value
Me.Protocol_ID.DefaultValue = DLookup("ProtocolID", "tblDefaults")
' Fill in Protocol Title
Me.Protocol_Title.DefaultValue = """" & _
DLookup("ProtocolTitle", "tblDefaults") & """"
End If

ExitPoint:
Exit Sub


Error_Handler:
If Err.Number = 2467 Then
' Ignore
Else
' Unexpected Error
MsgBox "An unanticipated error has occurred." & _
"The error number is " & Err.Number & _
" and the description is '" & Err.description & "'" & _
" Please contact your System Administrator."
End If
Resume ExitPoint

End Sub


hopefully someone knows how serious this is if i don't treat it or how to
purge the code of the bug if it is going to be treated.

-
 
W

Wayne Morgan

If IsNull(Forms![Command and Control Center]!SelectPatient) _
Or IsNull(Forms![Command and Control Center]!SelectCycle) Then
' No Patient ID or Cycle entered on main form
MsgBox "Please select a Patient Number and/or Cycle from " _
& "the list provided before continuing." _
, vbInformation, "Which Patient/Cycle?"
' Stop the form from opening
Cancel = True
Resume ExitPoint
End If

The Resume ExitPoint in this section should read

GoTo ExitPoint
or
Exit Sub

There is no error, you're just trying to jump to another point.

--
Wayne Morgan
MS Access MVP


Ted said:
when i run this on my form i get the following: "An unanticipated error
has
occurred. The error number is 20 and the description is 'Resume without
error'. Please contact your System
Administrator"

this code is meant to be used on the same form; the form can be accessed
from w/in a 'Baseline', 'Treatments' or 'Follow Up' switchboard page.

i want the user to be forced to enter both the patient number AND cycle
number from the main s'board page. also, when the inappropriate value of
the
cycle number (given the switchboard page the form's being opened from) is
entered in the main s'board page, i want the user to be prompted to enter
the
correct one.

can you see where the fatal flaw in my logic lies here?

Private Sub Form_Open(Cancel As Integer)
On Error GoTo Error_Handler

' using "ApplyFilter" and "Ted" search string on MS discussion groups
(3/16/2005)'

If IsNull(Forms![Command and Control Center]!SelectPatient) _
Or IsNull(Forms![Command and Control Center]!SelectCycle) Then
' No Patient ID or Cycle entered on main form
MsgBox "Please select a Patient Number and/or Cycle from " _
& "the list provided before continuing." _
, vbInformation, "Which Patient/Cycle?"
' Stop the form from opening
Cancel = True
Resume ExitPoint
End If

Select Case Forms![Command and Control Center]![SwitchboardID]
' this is the Baseline case
Case 2

If [Forms]![Command and Control Center]![SelectCycle] <> 0 Then
MsgBox "You need to enter a Cycle of 0 to access this form"
Cancel = True
End If

' this is the Treatment Case

Case 21
If [Forms]![Command and Control Center]![SelectCycle] <= 1 Or _
[Forms]![Command and Control Center]![SelectCycle] >= 99 Then
MsgBox "You need to enter a Cycle between 1 and 100 to access this
form"
Cancel = True
End If

' this is the Follow Up Case

Case 22

If [Forms]![Command and Control Center]![SelectCycle] < 100 Then
MsgBox "You need to enter a Cycle greater of at least 100 to access
this form"
Cancel = True
End If

Case Else

MsgBox "Nothing here just ignore - we should never get to this
switchboard page"

End Select

' Check to see if Final Answer has been entered
If DLookup("FinalAnswer", "tblDefaults") = False Then
' Missing information
MsgBox "The correct Protocol ID and Title have not " _
& "been entered into the database." & vbNewLine _
& "Notify the Administrator. At this time you can " _
& "not enter data into the database.", 64 _
, "Warning -- Read Before Proceeding!"
' Stop the form from opening
Cancel = True
Else
' All clear, continue with form opening
' Patient ID was selected on main form
' Run Security Code
LAS_EnableSecurity Me
' Maximize the form
DoCmd.Maximize
' Apply a filter to match chosen Patient Number and set Cycle
to 0
' the basline case
If [Forms]![Command and Control Center]![SwitchboardID] = 2
Then
DoCmd.ApplyFilter , "[Patient Number] = " & _
[Forms]![Command and Control Center]![SelectPatient] & " And
[Cycle] = 0"
' the treatment (21) or follow up (24) case
ElseIf [Forms]![Command and Control Center]![SwitchboardID] =
21 _
Or [Forms]![Command and Control Center]![SwitchboardID] = 24
Then
DoCmd.ApplyFilter , "[Patient Number] = " & _
[Forms]![Command and Control Center]![SelectPatient] & _
" And [Cycle] = " & [Forms]![Command and Control
Center]![SelectCycle]
End If
' Fill in Protocol ID value
Me.Protocol_ID.DefaultValue = DLookup("ProtocolID",
"tblDefaults")
' Fill in Protocol Title
Me.Protocol_Title.DefaultValue = """" & _
DLookup("ProtocolTitle", "tblDefaults") & """"
End If

ExitPoint:
Exit Sub


Error_Handler:
If Err.Number = 2467 Then
' Ignore
Else
' Unexpected Error
MsgBox "An unanticipated error has occurred." & _
"The error number is " & Err.Number & _
" and the description is '" & Err.description & "'" & _
" Please contact your System Administrator."
End If
Resume ExitPoint

End Sub


hopefully someone knows how serious this is if i don't treat it or how to
purge the code of the bug if it is going to be treated.

-
 
G

Guest

wayne,

can you explain (to this newbie) what the difference is?

-ted

Wayne Morgan said:
If IsNull(Forms![Command and Control Center]!SelectPatient) _
Or IsNull(Forms![Command and Control Center]!SelectCycle) Then
' No Patient ID or Cycle entered on main form
MsgBox "Please select a Patient Number and/or Cycle from " _
& "the list provided before continuing." _
, vbInformation, "Which Patient/Cycle?"
' Stop the form from opening
Cancel = True
Resume ExitPoint
End If

The Resume ExitPoint in this section should read

GoTo ExitPoint
or
Exit Sub

There is no error, you're just trying to jump to another point.

--
Wayne Morgan
MS Access MVP


Ted said:
when i run this on my form i get the following: "An unanticipated error
has
occurred. The error number is 20 and the description is 'Resume without
error'. Please contact your System
Administrator"

this code is meant to be used on the same form; the form can be accessed
from w/in a 'Baseline', 'Treatments' or 'Follow Up' switchboard page.

i want the user to be forced to enter both the patient number AND cycle
number from the main s'board page. also, when the inappropriate value of
the
cycle number (given the switchboard page the form's being opened from) is
entered in the main s'board page, i want the user to be prompted to enter
the
correct one.

can you see where the fatal flaw in my logic lies here?

Private Sub Form_Open(Cancel As Integer)
On Error GoTo Error_Handler

' using "ApplyFilter" and "Ted" search string on MS discussion groups
(3/16/2005)'

If IsNull(Forms![Command and Control Center]!SelectPatient) _
Or IsNull(Forms![Command and Control Center]!SelectCycle) Then
' No Patient ID or Cycle entered on main form
MsgBox "Please select a Patient Number and/or Cycle from " _
& "the list provided before continuing." _
, vbInformation, "Which Patient/Cycle?"
' Stop the form from opening
Cancel = True
Resume ExitPoint
End If

Select Case Forms![Command and Control Center]![SwitchboardID]
' this is the Baseline case
Case 2

If [Forms]![Command and Control Center]![SelectCycle] <> 0 Then
MsgBox "You need to enter a Cycle of 0 to access this form"
Cancel = True
End If

' this is the Treatment Case

Case 21
If [Forms]![Command and Control Center]![SelectCycle] <= 1 Or _
[Forms]![Command and Control Center]![SelectCycle] >= 99 Then
MsgBox "You need to enter a Cycle between 1 and 100 to access this
form"
Cancel = True
End If

' this is the Follow Up Case

Case 22

If [Forms]![Command and Control Center]![SelectCycle] < 100 Then
MsgBox "You need to enter a Cycle greater of at least 100 to access
this form"
Cancel = True
End If

Case Else

MsgBox "Nothing here just ignore - we should never get to this
switchboard page"

End Select

' Check to see if Final Answer has been entered
If DLookup("FinalAnswer", "tblDefaults") = False Then
' Missing information
MsgBox "The correct Protocol ID and Title have not " _
& "been entered into the database." & vbNewLine _
& "Notify the Administrator. At this time you can " _
& "not enter data into the database.", 64 _
, "Warning -- Read Before Proceeding!"
' Stop the form from opening
Cancel = True
Else
' All clear, continue with form opening
' Patient ID was selected on main form
' Run Security Code
LAS_EnableSecurity Me
' Maximize the form
DoCmd.Maximize
' Apply a filter to match chosen Patient Number and set Cycle
to 0
' the basline case
If [Forms]![Command and Control Center]![SwitchboardID] = 2
Then
DoCmd.ApplyFilter , "[Patient Number] = " & _
[Forms]![Command and Control Center]![SelectPatient] & " And
[Cycle] = 0"
' the treatment (21) or follow up (24) case
ElseIf [Forms]![Command and Control Center]![SwitchboardID] =
21 _
Or [Forms]![Command and Control Center]![SwitchboardID] = 24
Then
DoCmd.ApplyFilter , "[Patient Number] = " & _
[Forms]![Command and Control Center]![SelectPatient] & _
" And [Cycle] = " & [Forms]![Command and Control
Center]![SelectCycle]
End If
' Fill in Protocol ID value
Me.Protocol_ID.DefaultValue = DLookup("ProtocolID",
"tblDefaults")
' Fill in Protocol Title
Me.Protocol_Title.DefaultValue = """" & _
DLookup("ProtocolTitle", "tblDefaults") & """"
End If

ExitPoint:
Exit Sub


Error_Handler:
If Err.Number = 2467 Then
' Ignore
Else
' Unexpected Error
MsgBox "An unanticipated error has occurred." & _
"The error number is " & Err.Number & _
" and the description is '" & Err.description & "'" & _
" Please contact your System Administrator."
End If
Resume ExitPoint

End Sub


hopefully someone knows how serious this is if i don't treat it or how to
purge the code of the bug if it is going to be treated.

-
 
J

Jeff Conrad

Follow Wayne's instructions and/or see the new code I posted in your
original thread Ted.

--
Jeff Conrad
Access Junkie
Bend, Oregon

when i run this on my form i get the following: "An unanticipated error has
occurred. The error number is 20 and the description is 'Resume without
error'. Please contact your System
Administrator"

this code is meant to be used on the same form; the form can be accessed
from w/in a 'Baseline', 'Treatments' or 'Follow Up' switchboard page.

i want the user to be forced to enter both the patient number AND cycle
number from the main s'board page. also, when the inappropriate value of the
cycle number (given the switchboard page the form's being opened from) is
entered in the main s'board page, i want the user to be prompted to enter the
correct one.

can you see where the fatal flaw in my logic lies here?

Private Sub Form_Open(Cancel As Integer)
On Error GoTo Error_Handler

' using "ApplyFilter" and "Ted" search string on MS discussion groups
(3/16/2005)'

If IsNull(Forms![Command and Control Center]!SelectPatient) _
Or IsNull(Forms![Command and Control Center]!SelectCycle) Then
' No Patient ID or Cycle entered on main form
MsgBox "Please select a Patient Number and/or Cycle from " _
& "the list provided before continuing." _
, vbInformation, "Which Patient/Cycle?"
' Stop the form from opening
Cancel = True
Resume ExitPoint
End If

Select Case Forms![Command and Control Center]![SwitchboardID]
' this is the Baseline case
Case 2

If [Forms]![Command and Control Center]![SelectCycle] <> 0 Then
MsgBox "You need to enter a Cycle of 0 to access this form"
Cancel = True
End If

' this is the Treatment Case

Case 21
If [Forms]![Command and Control Center]![SelectCycle] <= 1 Or _
[Forms]![Command and Control Center]![SelectCycle] >= 99 Then
MsgBox "You need to enter a Cycle between 1 and 100 to access this form"
Cancel = True
End If

' this is the Follow Up Case

Case 22

If [Forms]![Command and Control Center]![SelectCycle] < 100 Then
MsgBox "You need to enter a Cycle greater of at least 100 to access
this form"
Cancel = True
End If

Case Else

MsgBox "Nothing here just ignore - we should never get to this
switchboard page"

End Select

' Check to see if Final Answer has been entered
If DLookup("FinalAnswer", "tblDefaults") = False Then
' Missing information
MsgBox "The correct Protocol ID and Title have not " _
& "been entered into the database." & vbNewLine _
& "Notify the Administrator. At this time you can " _
& "not enter data into the database.", 64 _
, "Warning -- Read Before Proceeding!"
' Stop the form from opening
Cancel = True
Else
' All clear, continue with form opening
' Patient ID was selected on main form
' Run Security Code
LAS_EnableSecurity Me
' Maximize the form
DoCmd.Maximize
' Apply a filter to match chosen Patient Number and set Cycle to 0
' the basline case
If [Forms]![Command and Control Center]![SwitchboardID] = 2 Then
DoCmd.ApplyFilter , "[Patient Number] = " & _
[Forms]![Command and Control Center]![SelectPatient] & " And
[Cycle] = 0"
' the treatment (21) or follow up (24) case
ElseIf [Forms]![Command and Control Center]![SwitchboardID] = 21 _
Or [Forms]![Command and Control Center]![SwitchboardID] = 24 Then
DoCmd.ApplyFilter , "[Patient Number] = " & _
[Forms]![Command and Control Center]![SelectPatient] & _
" And [Cycle] = " & [Forms]![Command and Control
Center]![SelectCycle]
End If
' Fill in Protocol ID value
Me.Protocol_ID.DefaultValue = DLookup("ProtocolID", "tblDefaults")
' Fill in Protocol Title
Me.Protocol_Title.DefaultValue = """" & _
DLookup("ProtocolTitle", "tblDefaults") & """"
End If

ExitPoint:
Exit Sub


Error_Handler:
If Err.Number = 2467 Then
' Ignore
Else
' Unexpected Error
MsgBox "An unanticipated error has occurred." & _
"The error number is " & Err.Number & _
" and the description is '" & Err.description & "'" & _
" Please contact your System Administrator."
End If
Resume ExitPoint

End Sub


hopefully someone knows how serious this is if i don't treat it or how to
purge the code of the bug if it is going to be treated.

-
 
W

Wayne Morgan

The Resume statement is part of an Error Handler. It tells Access how to
handle an error. It may be to go to a certain point, as you have it in this
case, or it could be other things such as Resume Next which will resume on
the line after the error or just Resume which will resume with the line that
created the error.

A GoTo statement can be used to move to a label in the code. The reason you
could use GoTo or Exit Sub in this case is because the only thing you are
doing once you get to ExitPoint is Exit Sub (the next line after ExitPoint
is Exit Sub, so if you go to ExitPoint, that is all you're going to do
anyway, so you could just simply Exit Sub rather issuing the GoTo).

Why the difference between GoTo and Resume? They are for two different
things. Part of their functionality has been designed the same, but not all
of it. Computers are actually quite stupid. They've been told to do this
when they see that. They don't like changes to that, even if it is something
simple that a person could easily reason out. You have to use the defined
syntax, which may be more than one line long, such as a Next following a For
or a Loop following a Do. If you try to Loop without a Do, you'll get an
error. If you try to Resume without an error you'll get an error.
 

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