T
Ted
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.
-
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.
-