default date without weekends

A

adrian

How do i make my date field on my Form show 3 days from
today as defaultvalue:

If Today is Monday(Jan 01,2004), then my field wil show
Thursday's date(Jan 04, 2004)

and if Today is Friday(Jan 05, 2004) then my field will
show wendesday's date (Jan 10, 2004)

Can anyone help?? thanks....
 
J

Jonathan Parminter

Hi Adrian,

you can use the Form_OnCurrent() event to check whether
the date control is null. If true then use the dateadd
function. Use online help for more information on this
function (in VBE type 'dateadd', press F1)

Private Sub Form_OnCurrent()
if isnull(txtDate) then
txtDate=DateAdd("w", 3, Date())
end if
End Sub

Luck
Jonathan
 
A

Alan Fisher

-----Original Message-----
Hi Adrian,

you can use the Form_OnCurrent() event to check whether
the date control is null. If true then use the dateadd
function. Use online help for more information on this
function (in VBE type 'dateadd', press F1)

Private Sub Form_OnCurrent()
if isnull(txtDate) then
txtDate=DateAdd("w", 3, Date())
end if
End Sub
try this on your On Load event of the form

Dim datDate As Date
datDate = DateAdd("D", 3, Date)
Select Case Weekday(datDate)
Case vbSaturday
Me.txtTest = DateAdd("d", 5, Date)
Case vbSunday
Me.txtTest = DateAdd("d", 5, Date)
Case Else
Me.txtTest = DateAdd("d", 3, Date)
End Select
 
J

Jonathan Parminter

hi Alan,

If you notice in my example I used the "w" switch. Uing
this switch to add weekdays (that is not including
weekends) means further testing with select case is not
required...

Luck
Jonathan
 
G

Guest

both works fine but if i had to work on saturday what happens! looks like it count sunday as one day
 

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