Results 1 to 8 of 8
  1. #1
    MHernan1 is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2012
    Posts
    18

    Auto popluate data from one field to another field in the same record

    Hello all,

    Lots of questions today...

    I have 2 fields, a "Total' field and a "Submitted" field. The 'Total' field value will never change as it is used for reporting purposes but the 'Submitted' field will be edited as the work is completed but the initial value should be the same as the 'Total' field.

    Is there a way to have the data in the 'Total' be set as the default value for the 'Submitted' field?

    Thanks!

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    How is the data in the "Total" field initially loaded? I am thinking you want some VBA code or Update Query that will copy that value over to the "Submitted" field when it is first populated.
    How that is triggered is dependent upon how that Total field is being populated initially (through a Form, import, etc).

  3. #3
    MHernan1 is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2012
    Posts
    18
    The 'Total' field will be manually entered via a form...when you say "Update Query", would that be something like a button they could click on the form when initially entering the data in the form that would run the query and update the appropriate field? Sorry, still kind of new to access, just trying to visualize the flow.

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    I think that all you need is one line of code in the After Update event of the "Total" textbox. Something like:

    Me.OtherTextBox = Me.ActiveControl
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Yep, Bob took this where I was going with it. Only one other thing I would add though. I think you want to check to see if the value in Submitted is Null before you default it. Otherwise, if you enter something so both get populated, and then go back and want to change the Total value, the Submitted amount will change automatically too, even if you do not want it to. To prevent that, your code would look something like:
    Code:
    Private Sub txtTotal_AfterUpdate()
        If IsNull(Me.txtSubmitted) Then
            Me.txtSubmitted = Me.txtTotal
        End If
    End Sub

  6. #6
    MHernan1 is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2012
    Posts
    18
    You guys rock, thanks so much for the help!

  7. #7
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    You guys rock, thanks so much for the help!
    You're welcome. Good luck with your project.
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  8. #8
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Your welcome, glad we could help!

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

Similar Threads

  1. Replies: 3
    Last Post: 07-26-2012, 03:55 PM
  2. Replies: 6
    Last Post: 04-27-2012, 01:31 PM
  3. Pulling field data from another record's field?
    By PeachTosser25 in forum Access
    Replies: 7
    Last Post: 02-06-2012, 01:14 PM
  4. Replies: 9
    Last Post: 06-20-2011, 03:42 PM
  5. Auto fill field upon New Record selected
    By NOTLguy in forum Programming
    Replies: 27
    Last Post: 12-05-2010, 05:12 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