none
Access form: Default value of date, 1 day more than previous records value? RRS feed

  • Question

  • I am trying to set the value of a date field (Date) to one day higher than
    the previous records entry. 1/1/2017 next record will auto fill in 1/2/2017

    any suggestions would be appreciated

    Wednesday, October 4, 2017 4:16 AM

All replies

  • Hi

    My idea is to use a query and an Add query.

    The first: "FindMaxDateInTable"

    SELECT Max(TABLENAME.FIELDNAMEforTheDate) AS MaxDate
    FROM TABLENAME;

    The Add:"AddMaxDatePlusOne"

    INSERT INTO TABLENAME( FIELDNAMEforTheDate )
    SELECT [MaxDate]+1 AS OneMoreDay
    FROM FindMaxDateInTable;



    Best // Peter Forss Stockholm GMT +1.00


    Wednesday, October 4, 2017 8:26 AM
  • Thank you so much !! I will try it to see it work for me or not
    Thursday, October 5, 2017 3:16 PM
  • Hello,

    In the form, you could handle AfterInsert event to auto fill the date field.

    E.g.

    Private Sub Form_AfterInsert()
    Me.Field1 = DMax("Field1", "Table1") + 1
    End Sub

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, October 6, 2017 6:57 AM
    Moderator