Public Function HotKeySaveRecord()
'Purpose:
'This function is called by the F8 hot key, via the AutoKeys macro.
'It's purpose is to support both "normal", bound forms that use the global
'SaveRecord() function (in basApplUtilities) to perform the Save Record operation;
'and other forms (such as unbound forms like Priority) that need to
'have a special-purpose SaveRecord() function defined on the form itself.
'It will first try to execute a SaveRecord() function on the currently active form.
'If this returns an error 2465, then it will go on to execute the global
'SaveRecord() function.
'
On Error GoTo ErrorHandler
'Declarations
Const strProcedureName = "HotKeySaveRecord"
Dim varTemp
Dim frm As Form
'Make sure there is an active form.
'If the user requested SaveRecord in some odd circumstance,
'we'll just do nothing.
On Error Resume Next
Set frm = Screen.ActiveForm
If Err.Number <> 0 Then
GoTo ExitRoutine
End If
On Error GoTo ErrorHandler
'See if we can execute a SaveRecord() function on the current form.
On Error Resume Next
varTemp = frm.SaveRecord()
gobjLastError.Save Err, strProcedureName
On Error GoTo ErrorHandler
'Now inspect gobjLastError to see whether or not we found a form-specific SaveRecord().
Select Case gobjLastError.Number
Case 0 'No error. The current form did have a SaveRecord() function.
'Do nothing
Case 2465 'Current form did not have a SaveRecord() function.
'Execute the global SaveRecord() function.
varTemp = SaveRecord()
Case Else 'Some other error happened.
gobjLastError.Raise gobjLastError.Number & ": " & gobjLastError.Description
End Select
ExitRoutine:
Exit Function
ErrorHandler:
gobjLastError.Save Err, strProcedureName
Select Case gobjLastError.Number
Case Else
gobjLastError.Show
Resume ExitRoutine
End Select
End Function
|