Results 1 to 10 of 10
  1. #1
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581

    Keeping information going to a new record


    I have a form with bound and unbound fields. When I do a command to go to a new record: DoCmd.GoToRecord , "", acNewRec my unbound fields disappear. Is there a way to keep my unbound fields and only go to a new record with my bound fields?

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,859
    You save them to variables and repopulate them from the variables when adding a new record?

  3. #3
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    You mean save them to table then repopulate?

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,859
    Quote Originally Posted by UT227 View Post
    You mean save them to table then repopulate?
    No, just save to form/global variable or TempVars and then repopulate.

    If you want them as a sort of default for a user, then yes, save them to a table.

    If not that, then you just need to hold on to them when your created a new record as you can reuse from that new record, as one or two might have changed?

    HTH

  5. #5
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    You have a link on how to do that?

  6. #6
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,859
    Quote Originally Posted by UT227 View Post
    You have a link on how to do that?
    Just simple VBA code

    strFirstName = Me.FirstName

    Do your New record code here

    Me.FirstName = strFirstName

    That assumes you have a control called FirstName, amend the names to suit.

  7. #7
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    strFirstName needs to be defined?

  8. #8
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    Got it. Works great. Thanks. To remove the TempVars?
    TempVars!RemoveAll?

  9. #9
    UT227 is offline Expert
    Windows 7 32bit Access 2013 32bit
    Join Date
    Feb 2016
    Posts
    581
    TempVars.RemoveAll

    Thanks

  10. #10
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,859
    Quote Originally Posted by UT227 View Post
    strFirstName needs to be defined?
    You should *ALWAYS* have Option Explicit at the top of every module. That can be set automatically for new modules in VBA window options Require Variable Declaration.
    You will need to add it for any existing modules if that is not set.

    Then Access will tell you if any are missing/misstyped.

    HTH

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

Similar Threads

  1. Attendance Record - Keeping
    By Clifford86 in forum Programming
    Replies: 1
    Last Post: 12-31-2019, 09:24 PM
  2. Holding/Keeping fields after record added
    By ShennyP in forum Forms
    Replies: 9
    Last Post: 03-05-2019, 08:13 PM
  3. Keeping on the same record while changing forms
    By TomBrierley in forum Forms
    Replies: 5
    Last Post: 09-04-2016, 08:25 PM
  4. Replies: 1
    Last Post: 12-23-2014, 01:23 PM
  5. Replies: 2
    Last Post: 08-21-2012, 02:38 PM

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