Results 1 to 9 of 9
  1. #1
    RLehrbass is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    102

    Question cmd btn works correctly in form Add mode but not in form Edit Mode?

    Ok,
    If I load the form [frmMember] in 'Add mode', fill it out, click my save button (performs DoCmd.RunCommand acCmdSaveRecord) the cmdAddANewMember button on frmMember works correctly and re-loads frmMember in 'Add Mode', but...


    If I load the form [frmMember] in 'Edit mode', whether I make some Edits or not, and/or click the Save button or not, the same cmdAddANewMember button says
    "You can't go to the specified record."

    How can I correct this to work in both 'Add Mode' and 'Edit Mode' conditions?
    or better yet, how can I make the cmdAddANewMember button disapear in the edit mode???

    This is the Code I am using at this time:

    Private Sub cdmAddANewMember_Click()
    On Error GoTo Err_cdmAddANewMember_Click

    DoCmd.GoToRecord , , acNewRec

    Exit_cdmAddANewMember_Click:
    Exit Sub

    Err_cdmAddANewMember_Click:
    MsgBox Err.Description
    Resume Exit_cdmAddANewMember_Click

    End Sub

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Can you show the code you are using for Edit mode? Perhaps the type of editing you wish to do is not what the code is asking Access to do.

  3. #3
    RLehrbass is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    102
    Its the same form, the only thing different is from the switchboard, i have a add new member and a edit/view new member selection.
    Both load the same form.
    I have attached the DB for your review of this issue.

    Membership-database-ConstructionFormIsWorking62515.zip

    FYI, I am A Novice and I knew nothing of VBA prior to creating this DB...
    I started with the Membership DB template and have seriously modified the heck out of this.
    Moderator has helped me greatly over the past few weeks with some of the forms financial coding issues.
    I have not gotten to the reports area yet, so what reports exist are not mine and do not apply.
    I have not removed them so I will have basic reports to review when making my reports.
    I have played with a few reports just to see what they are like.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I looked at your DB. The form named frmMember had its Allow Additions property set to = No.

    You can adjust this to = Yes via the property sheet while in Design View of the form. The Allow Additions property is under the Data Tab.

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Set the form properties as needed.

    Me.AllowAdditions = True
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    RLehrbass is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    102
    Moderator,
    How would I apply your suggestion. Would it be inserted into the cmdAddANewMember_Click() code?
    I actually did not set the allow additions property to no, I believe this was done by Access in the view in edit mode setting of the switchboard.
    Would you recommend to change the property or add the code?

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    If you want to keep switching back and forth between allowing new and not allowing new, then use code behind the buttons. Setting AllowAdditions to yes in form design won't help if you then open the form in Edit mode. If you then want to add record, will need to change the form's 'mode'.

    Why bother with Edit mode? Just open form filtered to the one record to edit. This will still allow movement to new record row if the AllowAdditions property is set to yes. Users won't be able to navigate to other records. One form can be made to work so users can navigate all records, find a specific record, add new record. This can be done with intrinsic tools or through custom buttons and code. The more 'user friendly', the more code.

    The save record command might not be needed. Record is committed to table when move to another record, close form, or run SaveRecord code.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    RLehrbass is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    102
    Moderator,
    1) I changed the property field to additions = yes.
    2) I need to stay on the current record after inputting new member information, so i can either add committee member or payment from this form, without moving off record in some fashion then returning, the save button resolved it nicely. I tried refresh and requery but neither would actually save to the table without leaving current record. but then-again, that may also be due to the allow additions setting. Perhaps I was trying the code in the edit mode??? hence, next experiment! try refresh and requery with the allow add set to yes.

  9. #9
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Then that is reasonable use of save record code. Refresh and Requery will move focus to first record of the form's dataset, no matter what mode.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 11-26-2013, 10:47 AM
  2. Change form to edit mode using VBA
    By Richie27 in forum Programming
    Replies: 1
    Last Post: 06-05-2012, 04:39 AM
  3. Replies: 2
    Last Post: 09-01-2011, 10:48 PM
  4. Replies: 2
    Last Post: 03-03-2011, 12:48 PM
  5. Replies: 4
    Last Post: 01-14-2011, 10:37 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums