Question : called function not executing - why?

When the user presses F8, a macro is triggered that throws the user into this HotKeySaveRecord function. Its purpose is to call a SaveRecord function.    Since upgrading to Access 2007, this functionality no longer works.   When I step through this function, it just goes right thru the varTemp = frm.SaveRecord() line without ever entering the SaveRecord function. It doesn't error.

Any help you can provide would be much appreciated.  Thanks!

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
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

Answer : called function not executing - why?

Not sure why all that code is necessary.  The simplest way to save a record is the following.

On a form with a Save button:

Me.Dirty = False

IF ... you need a 'global' Save (?) ... then in a vba module:

Forms.YourFormName.Dirty = False

Or

Screen.ActiveForm.Dirty = False

mx
Random Solutions  
 
programming4us programming4us