Results 1 to 9 of 9
  1. #1
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Saving A Record (A2K SR1)

    I have a form with a subform. The form has a Save button with the following code:

    Private Sub SaveRec_Click()
    On Error GoTo Err_SaveRec_Click

    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
    Me.AllowEdits = False
    Me.AllowAdditions = False
    Me.AllowDeletions = False
    Me.sbfLINEITEMS.Form.AllowAdditions = False
    Me.sbfLINEITEMS.Form.AllowEdits = False
    Me.sbfLINEITEMS.Form.AllowDeletions = False
    Refresh

    Exit_SaveRec_Click:
    Exit Sub

    Err_SaveRec_Click:
    MsgBox "The Save Record function is unavailable because the record was not changed."
    Resume Exit_SaveRec_Click

    End Sub

    The Save button works as desired if I press it when I'm on the main form. AllowEdits, AllowAdditions, and AllowDeletions get set to False and the form (including the subform) is 'locked' again. However, when I press the Save button when I'm in the subform (sbfLINEITEMS), none of the Save button actions occur (AllowEdits, AllowAdditions, and AllowDeletions don't get set to False for either the main form or the subform). I've tried resetting the focus to a control on the main form before the Save actions occur...that didn't do anything. I know I'm missing something with regard to the interaction betweens forms and subforms, but I don't know what. Any help would be appreciated. Thank you.

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Saving A Record (A2K SR1)

    I take it that the Access 95 code in the DoCmd line is intended to save the current record? Why not use an updated line instead?

    DoCmd.RunCommand acCmdSaveRecord

    It won't change your problem, but it will make your code easier to read.

    As to your question, it works properly on my installation of A2k SR1. Is it possible you have something in the Current event of the form that is turning those settings back on again?
    Charlotte

  3. #3
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving A Record (A2K SR1)

    Charlotte,

    I have no Current event running.

    When I use your modified Save code, I get the error message presented in the routine I posted in my original message, even if I do change the record.

    I ran a test using the code from my original post. I placed a message box as the next line after the 6 lines of code resetting the switches. When I press the Save button when I'm in the main form, the message box appears. When I press the Save button when I'm in the subform, the message box does not appear (it looks like the routine is not getting past the SaveRecord command).

    Any help/suggestions would be appreciated. Thank you.

  4. #4
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving A Record (A2K SR1)

    Charlotte,

    I placed message boxes at the beginning and end of my Save Record routine. When in the main form, the routine works perfectly. However, when in the subform, when I press the Save Record button, absolutely nothing happens (the message boxes don't appear). I absolutely don't understand what's happening. Any suggestions would be appreciated.

  5. #5
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving A Record (A2K SR1)

    Do you have code in the On Exit event of the subform control, or in the subform itself or any control of the subform that can prevent accessing the saving function ?
    Francois

  6. #6
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving A Record (A2K SR1)

    Not that I can see. If you don't mind, I'll send you my DB so you can have a look. That way, we can post a cogent solution for everyone to see.

  7. #7
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving A Record (A2K SR1)

    No problem
    Francois

  8. #8
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving A Record (A2K SR1)

    Roy,

    In the subform sbfLineItems, in the after update event of the form, you have the line :
    Forms!frmsubinfo6!SaveRec.Enabled = False
    So when you change a record on this form, and go to the SaveButton, you update the record by leaving the subform and in the after update of the form you set the SaveRec button enabled to false and when you click on it, it is already disabled.
    If you comment this line out, the problem is solved.
    Francois

  9. #9
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Saving A Record (A2K SR1)

    Thanks for all of your help. This solved the problem. I have to try harder to remember what happens when the focus moves between forms and subforms. Thanks, again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •