default date without weekends

  • Thread starter Thread starter adrian
  • Start date Start date
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....
 
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
 
-----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
 
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
 
both works fine but if i had to work on saturday what happens! looks like it count sunday as one day
 
Back
Top