Results 1 to 9 of 9

Thread: Save Button

  1. #1
    Join Date
    Mar 2004
    Posts
    79

    Unanswered: Save Button

    I am trying to allow user to press command button to force record save if required fields are populated.

    When I am ready to save, I execute

    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

    I get the followig error. Help!

    Microsoft Office Access cannot find the macro '.'

  2. #2
    Join Date
    Sep 2004
    Location
    Raleigh, NC
    Posts
    146
    Quote Originally Posted by brmk
    I am trying to allow user to press command button to force record save if required fields are populated.

    When I am ready to save, I execute

    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

    I get the followig error. Help!

    Microsoft Office Access cannot find the macro '.'
    That code looks fine to me - sounds as though your problem is elsewhere. Can you post the rest of the sub?

  3. #3
    Join Date
    Mar 2004
    Posts
    79
    Here's the whole sub...it gives me the errors as I want but when it is able to get to the save button, I get the error.


    Private Sub cmdSave_Click()
    On Error GoTo Err_cmdSave_Click

    If IsNull(Me![CustName]) Then
    MsgBox "You must enter a customer name" & Err.Description, vbCritical, "System Error"
    Me![CustName].SetFocus
    ElseIf IsNull(Me![CustAddress1]) Then
    MsgBox "You must enter a customer address" & Err.Description, vbCritical, "System Error"
    Me![CustAddress1].SetFocus
    ElseIf IsNull(Me![CustCity]) Then
    MsgBox "You must enter a city" & Err.Description, vbCritical, "System Error"
    Me![CustCity].SetFocus
    ElseIf IsNull(Me![CustState]) Then
    MsgBox "You must enter a state" & Err.Description, vbCritical, "System Error"
    Me![CustState].SetFocus
    Else
    DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
    End If

    Exit_cmdSave_Click:
    Exit Sub

    Err_cmdSave_Click:
    MsgBox Err.Description
    Resume Exit_cmdSave_Click

    End Sub

  4. #4
    Join Date
    Sep 2004
    Location
    Raleigh, NC
    Posts
    146
    Strange, there doesn't appear to be anything wrong with the code. If you get a free moment, post the database file itself.

  5. #5
    Join Date
    Mar 2004
    Posts
    79
    The code in question is in frmCustMaster. Press Add Button to add record. Press save button to save record.

  6. #6
    Join Date
    Mar 2004
    Posts
    79
    Sorry...forgot the attachment.

    Code in question is in frmCustMaster. use Add Button to get new record. Add some data. Press Save...get error.

    Thanks.
    Attached Files Attached Files

  7. #7
    Join Date
    Sep 2004
    Location
    Raleigh, NC
    Posts
    146
    Quote Originally Posted by brmk
    Sorry...forgot the attachment.

    Code in question is in frmCustMaster. use Add Button to get new record. Add some data. Press Save...get error.

    Thanks.
    Open frmCustMaster in design view and take a peek at the form properties. Look for the "Before Update" property. There's a single space in that field which is what is causing your macro error. Remove the space and save the changes to the form and you're all set.

  8. #8
    Join Date
    Mar 2004
    Posts
    79

    Thumbs up Thanks

    Thanks. Works fine now.

  9. #9
    Join Date
    Jul 2009
    Posts
    185

    Question

    Do you have a updated mdb I am very interested on how you added the save/delete and add buttons to your form.

    I would appreciated it very much as I still leanring.

Posting Permissions

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