Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / November 2006

Tip: Looking for answers? Try searching our database.

Problem with Dates

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Don - 27 Nov 2006 13:31 GMT
I have a date control on my form.  When the form is opened, I want this
control to display the next scheduled workday.  I tried (control) = Date +1,
but could not get this to work.  Can someone point out what I'm doing wrong?  
Thanks...
Signature

Don Rountree

Dennis - 27 Nov 2006 13:43 GMT
Set the default value property of the control on your form to Date()+1

> I have a date control on my form.  When the form is opened, I want this
> control to display the next scheduled workday.  I tried (control) = Date +1,
> but could not get this to work.  Can someone point out what I'm doing wrong?  
> Thanks...
Al Campagna - 27 Nov 2006 13:51 GMT
Don,
  I'm assuming you mean that when you open a new record, that date field should always
display tomorrow's date.
  Set the field's DefaultValue to
       = Date() +1
  If that's not what you need, please provide more info...

Signature

hth
Al Campagna
Candia Computer Consulting - Candia NH
http://home.comcast.net/~cccsolutions

>I have a date control on my form.  When the form is opened, I want this
> control to display the next scheduled workday.  I tried (control) = Date +1,
> but could not get this to work.  Can someone point out what I'm doing wrong?
> Thanks...
Klatuu - 27 Nov 2006 14:45 GMT
Here are a pair of functions that will provide the information you want.  It
includes a Holiday table that has a record for each company holiday.  It does
not inlcue week end dates, only week day dates that are not working days.

You can use the Default Value property of your date control to populate the
date:

=NextWorDay(Date())

Be sure to use the parentheses with the date.

Public Function NextWorkDay(dtmSomeDay As Date)
   
   dtmSomeDay = DateAdd("d", 1, dtmSomeDay)
   Do Until IsWorkDay(dtmSomeDay)
       dtmSomeDay = DateAdd("d", 1, dtmSomeDay)
   Loop
   NextWorkDay = dtmSomeDay
End Function
******************************************
Public Function IsWorkDay(dtmSomeDay As Date) As Boolean
Dim blnWorkingDay
   blnWorkingDay = Weekday(dtmSomeDay, vbMonday) < 6
   If blnWorkingDay Then
       blnWorkingDay = IsNull(DLookup("[Holdate]", "Holidays", _
           "[Holdate] = #" & dtmSomeDay & "#"))
   End If
   IsWorkDay = blnWorkingDay
End Function

> I have a date control on my form.  When the form is opened, I want this
> control to display the next scheduled workday.  I tried (control) = Date +1,
> but could not get this to work.  Can someone point out what I'm doing wrong?  
> Thanks...
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.