Share via

Access Sequential Dates

Anonymous
2014-11-06T16:02:08+00:00

I am trying to get access to auto date an order entry. So 1/1/14 is a Monday and they are selling someone hot dog that day. 1/2/14 is Tuesday and they are selling them one Hamburger. Each day of the week is always assigned a specific food. People submit preorders and we have to enter the data into the database before it is served. I have a subtable for each order content and when adding them I want Access to automatically put the next date so I don't have to type in the 1/1/14, 1/2/14, etc.

Also it would be great if access automatically did not use weekend dates.

I am not able to code at all, and could not find any information on this so it might not even be possible.

Thanks in advance!

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

17 answers

Sort by: Most helpful
  1. Anonymous
    2014-11-08T17:25:33+00:00

    PS:  You presumably also meant the AfterInsert event procedure, Scott, not BeforeInsert.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2014-11-07T23:20:46+00:00

    I think you'll find that will interpret the return value of the DateAdd function as an arithmetical expression, which will evaluate to a very small number, and consequently set the default value to a date/time value around the end of the 19th century.  The DefaultValue property is always a string expression, regardless of the data type of the column in question, so should be wrapped in literal quotes characters:

    If Weekday(Me.Dateordered,vbMonday) <5 Then

         Me.DateOrdered.DefaultValue = """" & DateAdd("d",1,Me.DateOrdered) & """"

    Else

        Me.DateOrdered.DefaultValue = """" & DateAdd("d".3.Me.DateOrdered) & """"

    End If

    Was this answer helpful?

    0 comments No comments
  3. ScottGem 68,830 Reputation points Volunteer Moderator
    2014-11-07T20:54:24+00:00

    OK, then I would do this. In the Before Insert event of the form use code like this:

    If Weekday(Me.Dateordered,vbMonday) <5 Then

         Me.DateOrdered.DefaultValue = DateAdd("d",1,Me.DateOrdered)

    Else

        Me.DateOrdered.DefaultValue = DateAdd("d".3.Me.DateOrdered)

    End If

    So when they hit enter to go the Next line, the date should next weekday's date.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2014-11-07T20:10:56+00:00

    I have an order form and the subform (Food per order) shows on the main order form.

    They fill out all the administrative info and then they move to the subform where they enter each food item they will be serving.

    The subform on the main form is just the subtable. They input the food ordered for the first day and hit enter to go to the next line, etc.

    Was this answer helpful?

    0 comments No comments
  5. ScottGem 68,830 Reputation points Volunteer Moderator
    2014-11-07T19:58:57+00:00

    What's your exact process? The user creates an order, they then enter the order for the first day, Do they click an add button or do they use the builtin Add button in the Nav bar. Or do they just start typing in the next line of a continuous form?

    Was this answer helpful?

    0 comments No comments