A family of Microsoft relational database management systems designed for ease of use.
PS: You presumably also meant the AfterInsert event procedure, Scott, not BeforeInsert.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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!
A family of Microsoft relational database management systems designed for ease of use.
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.
PS: You presumably also meant the AfterInsert event procedure, Scott, not BeforeInsert.
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
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.
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.
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?