Add number of days to Order Date

G

Guest

In my order form, I have an order date and a due date. My order date is
always the current date.

I would like to be able click on the due date and a box pop up and ask for
the number of days until due. This number would then be added to my order
date to give me my outputed due date?

Is this possible, and if so can anyone help me with ideas suggestions?

Thanks,

Brook
 
G

Guest

the formula to use would be:
txtDueDate = dateadd("d",txtDaysTilDue,dteOrderDate)
It should probably go in the last event of the pop up you describes before
it closes. If you need to omit weekends and holidays as possible due dates,
then you need a routine to skip those days. I think I have one if you need
it.
 
G

Guest

Thank you for the information,

Can you please send me the code for the omit of weekends and holidays,
just so I can have it if I decide to use it?

What you mean by this should go in the last even of the popup?

Do you mean I should add the code to the on_close event of the popup?
Or should I set up a Yes / No cmd buttons on on the click even of the yes
button would activate the event, No would cancel the event?

Brook
 
G

Guest

ok, I have tried this and my field duedate is not being populated:

Here is what I have :

Order Date: Name - OrderDate, Format - Short Date
Due Date: Name - DueDate, Format - Short Date

Form: frmdaysdue
unbound Text Box: Name - txtDaysTilDue
a Yes cmdButton
***** Code Start *****
Private Sub cmdyes_Click()
On Error GoTo Err_cmdyes_Click
DueDate = DateAdd("d", txtDaysTilDue, OrderDate)

DoCmd.Close

Exit_cmdyes_Click:
Exit Sub

Err_cmdyes_Click:
MsgBox Err.Description
Resume Exit_cmdyes_Click

End Sub
***** Code End *****



a No cmdButton: Closes the form without changes

I don't understand why its not working?

Any ideas?

Brook
 
G

Guest

right after I sent the last message I thought that the pop up didn't know
where the duedate and orderdate where located.

For each of them I added: Forms!frmorders.duedate & Forms!frmorders.orderdate

thanks for all your help and responses to my questions..

Brook
 
G

Guest

Brook,
Glad you got it working! Here is the code to find out what the next work
day from a given date. note you will need a Holiday Table that has the dates
for all Holidays. It does eliminate Saturdays and Sundays, so you don't have
to work about that.

Function Next_Work_Date(dtmNextWorkDate As Date) As Date
Dim dbs As Database
Dim rstHoliday As Recordset 'Record set to eliminate Holidays
Dim blnFoundWorkDay As Boolean 'Found Next Business Day

Set dbs = CurrentDb()
Set rstHoliday = dbs.OpenRecordset("tblHoliday", dbOpenSnapshot,
dbReadOnly)
blnFoundWorkDay = False
dtmNextWorkDate = DateAdd("d", 1, dtmNextWorkDate)
Do Until blnFoundWorkDay 'Determine what the next business day is
If Weekday(dtmNextWorkDate, vbMonday) > 5 Then 'It is Saturday or
Sunday
dtmNextWorkDate = DateAdd("d", 1, dtmNextWorkDate) 'Look at
next day
Else
'See if the day is a holiday
rstHoliday.FindFirst ("[holiday_date] = #" & dtmNextWorkDate &
"#")
If rstHoliday.NoMatch Then 'Not a holiday
blnFoundWorkDay = True 'It is a business day
Else 'It is a holiday
dtmNextWorkDate = DateAdd("d", 1, dtmNextWorkDate) 'Look at
next day
End If
End If
Loop
Next_Work_Date = dtmNextWorkDate
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top