Record action Buttons on new Form not working

  • Thread starter BBC via AccessMonster.com
  • Start date
B

BBC via AccessMonster.com

I started a new project (Form) and included the navigation & record functions
bar from a previous project to manage this form. Although the navigation
functions work the record actions (New, Save, Delete, Undo & Form_Exit (Save
if needed & "Close") do not seem to work.
I created the form with the nav & record functions buttons (Nav bar) first
then added the form's RecordSource and then the controls. See the SaveRecd &
Form_Exit routines below.
It actually executes the functions when clicked but on doing the command

DoCmd.RunCommand acCmdSaveRecord
I receive an error
Error 2046 The command or action "SaveRecd" isn't available right now

Under some conditions (not clear what) on executing the Form_Exit, which then
calls this same SaveRecd routine, the SaveRecd actually works, but it never
works directly by clicking its button. If the called SaveRecd works the form
closes properly, if it fails so does the form Close.

It almost seems that these functions do not know about the recordsource or
bound controls, but then the Navigation buttons work ???

The "RecordAction" calls are back to the mainline to do any specific actions
required post/pre the requested action (ex prepare for the next record). In
this Form (so far) they do nothing. Both my "RecdDirty" and Me.Dirty are
true.

Please check out my (soon to be) next post where I'm trying to figure out how
to make these routine generic so I can have a common set in a Module and have
them work for all forms in the App. Right now they are private and included
with each form in an App

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
 

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