Results 1 to 4 of 4
  1. #1
    Douglasrac is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    92

    Question Field automatically filled

    Hi,



    I have a form with 4 fields. In the first field I will insert a date. When I press TAB and the focus goes to the second field, this field will be filled automatically with first field + 1 month.

    The code is the following, and it's working only for the first 2 fields.

    Code:
    Private Sub Parcela_1_AfterUpdate()
         Me.Parcela_2 = DateAdd("m", 1, Me.Parcela_1)
    End Sub
    ---------------------------------------------------------------
    Private Sub Parcela_2_AfterUpdate()
        Me.Parcela_3 = DateAdd("m", 1, Me.Parcela_2)
    End Sub
    ---------------------------------------------------------------
    Private Sub Parcela_3_AfterUpdate()
        Me.Parcela_4 = DateAdd("m", 1, Me.Parcela_3)
    End Sub
    ---------------------------------------------------------------
    Private Sub Parcela_4_AfterUpdate()
        Me.Parcela_5 = DateAdd("m", 1, Me.Parcela_4)
    End Sub
    ---------------------------------------------------------------

    So, when I put a date on field 1, I press TAB and field 2 is automatically filled with field 1 + 1 month. But when I press TAB again, field 3 do not get any date. Then I have to type, and when I press TAB field 4 is automatically filled with field 3 + 1 month. But field 5 (which exists) do not get any date. And it goes like this, until field 10.

    How can I solve this?

  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,640
    The after update event is not triggered by programmatic changes to the data, only user changes. You can either use the lost focus event or code all your updates.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Douglasrac is offline Advanced Beginner
    Windows 7 Access 2007
    Join Date
    Nov 2010
    Posts
    92

    Talking

    Quote Originally Posted by pbaldy View Post
    The after update event is not triggered by programmatic changes to the data, only user changes. You can either use the lost focus event or code all your updates.
    Thanks for the tip. Works perfectly

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Happy to help!
    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. Automatically update field
    By Top Fuel Friday in forum Forms
    Replies: 3
    Last Post: 02-12-2011, 12:14 PM
  2. Replies: 2
    Last Post: 09-20-2010, 09:02 PM
  3. Replies: 4
    Last Post: 01-19-2010, 05:36 AM
  4. Automatically Reduce Field Size
    By Rebecca in forum Access
    Replies: 4
    Last Post: 01-06-2010, 10:14 PM
  5. Replies: 0
    Last Post: 10-14-2009, 02:44 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