B
BBC via AccessMonster.com
I currently have a number of Navigation & Record Action Buttons that I am
trying to standardize on my vaious forms on a number of Apps/projects. These
include First,Previous,Next,Last and Save,New,Undo,Delete,FormExit (ie close).
Currently I include a Private copy of these for each Form in an App. I'd
like to put them in a single Module (in an App) and be able to call them from
any form in the App.
I do not know how to make them know which (bound) table (when in a common
Module) is the one they are supposed to be acting upon.
Also how to make the calls back to the specific Forms mainline work (
"RecordAction(...)" & "Move_Record(...)" ) . Is there a better way to do this
??
Sample code for 3 of these common routines is below
************************
Please also see my related post "Record action Buttons on new Form not
working"
************************
Private Sub fSaveRecd_Click()
On Error GoTo Error_Handler
Screen.PreviousControl.SetFocus
If RecdDirty Then
DoCmd.RunCommand acCmdSaveRecord
RecordAction ("Save") ' any special form dependent post-save/next recd
processing
Else
Beep
End If
Exit_Point:
Exit Sub
Error_Handler:
If Err.Number = 0 Then
' Adjust this test to deal with any special cases & known errors
Resume Exit_Point
Else
MsgBox "Error: " & Err.Number & ": " & Err.Description, , "Error
during Save Record"
Resume Exit_Point
End If
End Sub
Private Sub FormExit_Click()
Dim Recdsave As Integer
Recdsave = Proceed(RecdDirty Or Me.Dirty)
If Recdsave = vbCancel Then Exit Sub
If Recdsave = vbYes Then
fSaveRecd_Click
Else
Me.Undo
End If
On Error GoTo Error_Handler
RecordAction ("Exit") ' any special form dependent pre-Exit processing
DoCmd.Close , ""
Exit_Point:
Exit Sub
Error_Handler:
If Err.Number = 0 Then
' Adjust this test to deal with any special cases & known errors
Resume Exit_Point
Else
MsgBox "Error: " & Err.Number & ": " & Err.Description, , "Error
during Form Exit/Close"
Resume Exit_Point
End If
End Sub
*******************************************
An example Navigation Button routine (that works)
Private Sub fPrevRecd_Click()
Dim Recdsave As Integer
Recdsave = Proceed(RecdDirty)
If Recdsave = vbCancel Then Exit Sub
If Recdsave = vbYes Then fSaveRecd_Click
On Error GoTo Error_Handler
DoCmd.GoToRecord , "", acPrevious
Move_Record ("Previous") ' any special form dependent post-recd_movement
processing
Exit_Point:
Exit Sub
Error_Handler:
If Err.Number = 0 Then
' Adjust this test to deal with any special cases or KNown situations
Resume Exit_Point
Else
MsgBox "Error: " & Err.Number & ": " & Err.Description, , "Error
during Previous Record"
Resume Exit_Point
End If
End Sub
trying to standardize on my vaious forms on a number of Apps/projects. These
include First,Previous,Next,Last and Save,New,Undo,Delete,FormExit (ie close).
Currently I include a Private copy of these for each Form in an App. I'd
like to put them in a single Module (in an App) and be able to call them from
any form in the App.
I do not know how to make them know which (bound) table (when in a common
Module) is the one they are supposed to be acting upon.
Also how to make the calls back to the specific Forms mainline work (
"RecordAction(...)" & "Move_Record(...)" ) . Is there a better way to do this
??
Sample code for 3 of these common routines is below
************************
Please also see my related post "Record action Buttons on new Form not
working"
************************
Private Sub fSaveRecd_Click()
On Error GoTo Error_Handler
Screen.PreviousControl.SetFocus
If RecdDirty Then
DoCmd.RunCommand acCmdSaveRecord
RecordAction ("Save") ' any special form dependent post-save/next recd
processing
Else
Beep
End If
Exit_Point:
Exit Sub
Error_Handler:
If Err.Number = 0 Then
' Adjust this test to deal with any special cases & known errors
Resume Exit_Point
Else
MsgBox "Error: " & Err.Number & ": " & Err.Description, , "Error
during Save Record"
Resume Exit_Point
End If
End Sub
Private Sub FormExit_Click()
Dim Recdsave As Integer
Recdsave = Proceed(RecdDirty Or Me.Dirty)
If Recdsave = vbCancel Then Exit Sub
If Recdsave = vbYes Then
fSaveRecd_Click
Else
Me.Undo
End If
On Error GoTo Error_Handler
RecordAction ("Exit") ' any special form dependent pre-Exit processing
DoCmd.Close , ""
Exit_Point:
Exit Sub
Error_Handler:
If Err.Number = 0 Then
' Adjust this test to deal with any special cases & known errors
Resume Exit_Point
Else
MsgBox "Error: " & Err.Number & ": " & Err.Description, , "Error
during Form Exit/Close"
Resume Exit_Point
End If
End Sub
*******************************************
An example Navigation Button routine (that works)
Private Sub fPrevRecd_Click()
Dim Recdsave As Integer
Recdsave = Proceed(RecdDirty)
If Recdsave = vbCancel Then Exit Sub
If Recdsave = vbYes Then fSaveRecd_Click
On Error GoTo Error_Handler
DoCmd.GoToRecord , "", acPrevious
Move_Record ("Previous") ' any special form dependent post-recd_movement
processing
Exit_Point:
Exit Sub
Error_Handler:
If Err.Number = 0 Then
' Adjust this test to deal with any special cases or KNown situations
Resume Exit_Point
Else
MsgBox "Error: " & Err.Number & ": " & Err.Description, , "Error
during Previous Record"
Resume Exit_Point
End If
End Sub