Results 1 to 5 of 5
  1. #1
    djclntn is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    476

    How to repeat data?


    In a Form I have a Date field which is repeated many times from the previous Record. Is there any type of format or rule I can create whereby when I enter into a new Record the date from the preceding Record will automatically be entered?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  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,016
    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
    Note that this code/syntax can be used for any Datatype, including Dates.

    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
    djclntn is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2011
    Posts
    476
    I was unsuccessful at conquering my quest. Following the link that you provide assumingly I copied & pasted the code in VBA which didn’t work

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

    I also tried to copied/pasted the code below in VBA which didn’t work either.

    1. Private Sub YourControlName_AfterUpdate()
    2. Me.YourControlName.DefaultValue = """" & Me.YourControlName.Value & """"
    End SubM

    Maybe I’m not understanding these codes & what to do with them. Might you offer some further instructions or have other suggestions?

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    You would need to replace YourControlName with the actual name of yours, and enter the code via this path:

    http://www.baldyweb.com/FirstVBA.htm
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Do not repeat pictures
    By gabrielharo in forum Forms
    Replies: 1
    Last Post: 06-12-2012, 04:58 PM
  2. Replies: 3
    Last Post: 04-11-2012, 05:10 PM
  3. Repeat Expressions
    By welshmpf in forum Access
    Replies: 8
    Last Post: 09-06-2011, 09:41 AM
  4. IIF Expression - No Repeat Please
    By turnbuk in forum Queries
    Replies: 2
    Last Post: 08-11-2011, 02:50 PM
  5. Enter repeat identical data
    By wdrspens in forum Forms
    Replies: 1
    Last Post: 03-16-2011, 06:08 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