Results 1 to 7 of 7
  1. #1
    KerryAustin is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    27

    Navigate away from Form then back clears Form Data??

    I have a Form that is part of a Navigation Page with several forms. In form FormDelay I can enter information regarding procedural delay information. If a Team Member is not included in my cascading dropdown list I have a command button (+) Add Member that the user can click on that takes them to the Add Staff Member Form where they can enter information and onced saved is available in the dropdown. My problem is when the user returns to the FormDelay the data is cleared. I think this occurs because of my code which opens a new clean form when open.

    Private Sub cmdNew_Click()
    DoCmd.GoToRecord acActiveDataObject, , acNewRec
    Call CarryOver(Me)
    MyExit:
    Exit Sub
    MyErr:
    If Err.Number <> 2105 Then
    MsgBox Err.Description
    End If
    Resume MyExit
    End Sub



    I need to have code that if the form FormDelay is open and data has been initiated return to form with out opening new. I have included a view of my Form.

    I also have this code in my Add Member Form:

    Private Sub Form_Load()
    DoCmd.GoToRecord , , acNewRec
    End Sub


    Thank you all,

    Kerry A
    Attached Thumbnails Attached Thumbnails NavPage2.jpg  

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,527
    If 'DoCmd.GoToRecord , , acNewRec' executes then yes, it will clear the form.
    You'd need 1 form for viewing, then a different one for adding.

  3. #3
    KerryAustin is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    27
    Thats a pain in you know what! Is there a way to use an IF statement like if form is enables do not execute DoCmd.GoToRecord, else execute?

  4. #4
    hansendl is offline Advanced Hobbyist
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2012
    Posts
    38
    I would suggest you open the AddMember form as a popup, modal form. This way, the AddMember form appears as a dialog box and doesn't impact the record you're editing. Code would look something like this (assumes your Add Member button is named "cmdAddMember" and that your Add Member form is named "frmAddStaff"). You would place this code behind the click event of the cmdAddMember button:

    Code:
    Private Sub cmdAddMember_Click()
        DoCmd.OpenForm "frmAddStaff", , , , acFormAdd, acDialog
        'Add code here to requery the drop down list(s), such as:
        'Me.cboStaffMembers.Requery
    End Sub

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    As indicated in post #4 you can open forms in Add Mode by using the constant acDormAdd. Employing this in an OpenForm method would negate the need for DoCmd.GoToRecord , , acNewRec in your form's On Load Event.

  6. #6
    KerryAustin is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    27
    That work like a champ. Thanks for your quick fix.

  7. #7
    KerryAustin is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2014
    Posts
    27
    Thank you for the suggestion ItsMe. I will review up on this and make a few changes where I have the command.

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

Similar Threads

  1. How to navigate on tabbed form
    By JrMontgom in forum Programming
    Replies: 1
    Last Post: 09-03-2014, 12:53 PM
  2. Saving data back into a table from a form
    By skyview chick in forum Forms
    Replies: 22
    Last Post: 08-15-2012, 05:43 PM
  3. Replies: 1
    Last Post: 03-30-2012, 11:57 PM
  4. Replies: 6
    Last Post: 11-05-2010, 10:11 AM
  5. VBA to Navigate form
    By asmith in forum Access
    Replies: 3
    Last Post: 09-30-2010, 11:37 AM

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