Form Expression help

A

a_m101

Hi,

I am having a problem with an expression in a form that I am making.
It is for a library system. In one field I have the date a book wa
taken out. However, in another text box in the form, I need to buil
an expression which will calculate the due date of the book. The du
date has to be 1 calender month from when the book was taken out.

However, if the calender month gives a date due back on a Saturday o
Sunday, then the date must be automatically changed to the followin
Monday. i.e. a book due date cannot fall on a weekend.

I tried using the DateAdd function, but could not find a way o
changing the date to a Monday if the due date happened to fall on
weekend.

I appreciate any help.

Thank
 
Y

yakule

i think this should work for you:

Code
-------------------

Dim dueDate As Date

'get the due date one month from now
dueDate = DateAdd("m", 1, <check out date field>)

If Weekday(dueDate) = vbSunday Then
'check if due date is a sunday
'add one day if true
dueDate = DateAdd("d", 1, dueDate)
ElseIf Weekday(dueDate) = vbSaturday Then
'check if a due date is saturday
'add two days if true
dueDate = DateAdd("d", 2, dueDate)
End If

<due date field> = dueDate
 

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