Results 1 to 5 of 5
  1. #1
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273

    Save form textbox values


    I'm working on a form for people to enter visitor request information for approval, with controls such as txtRequestorName, txtVisitorName, txtStartDate, txtEndDate, etc. I'm adding a command button at the bottom to request another visitor, which would close the form (save), and open again for the next entry. I would like most of the textboxes to autofill with the same information from the previous request, as most requestors have more than one person visiting in the same time frame. I think I could use a DLookUp to enter the values from the most recent entry in the table, but this is very slow. Is there a way to store the values of these textboxes in VBA, close the form without losing the values, open the new form in add mode, and pass those values to the proper textboxes? I think this would happen much faster than a DLookUp, but I don't know if it's possible. If so, do I save the date values differently than the string values?

    As always, thank you for sharing your knowledge with the struggling masses.

  2. #2
    CJ_London is offline VIP
    Windows 8 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    you don't need to close the form and reopen it - just go to newrecord - and to pass the values tot he new record look at using the default value

    This thread has a similar requirement to yours

    http://www.access-programmers.co.uk/...t=defaultvalue

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    You can use the AfterUpdate event of the Control holding your data to set the DefaultValue for the Field. From that time forward, until you either manually change the data or close your form, the data will be entered automatically in each New Record.

    Code:
    Private Sub YourControlName_AfterUpdate()
       Me.YourControlName.DefaultValue = """" & Me.YourControlName.Value & """"
    End Sub

    This syntax is valid for Text, Number, DateTime and Boolean Datatypes.

    You’ll need to do this for each Control that you want to ‘carry forward.’

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    Posts
    273
    Awesome, you guys rock! Thanks again for all you do!

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Replies: 2
    Last Post: 08-12-2013, 05:47 PM
  2. Filter and Sort a form based on TextBox Values.
    By Ramun_Flame in forum Programming
    Replies: 7
    Last Post: 10-28-2012, 06:53 AM
  3. Replies: 2
    Last Post: 01-09-2012, 08:15 AM
  4. Replies: 4
    Last Post: 12-22-2011, 03:04 AM
  5. Replies: 4
    Last Post: 01-05-2011, 07:56 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