Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: RE: Date Difference for Workdays Only


Message #1 by "John Ruff" <papparuff@c...> on Tue, 3 Apr 2001 14:36:49 -0700
This is a multi-part message in MIME format.



------=_NextPart_000_0000_01C0BC4B.847BAA40

Content-Type: text/plain;

	charset="us-ascii"

Content-Transfer-Encoding: 7bit



Pam,



I need a little more help.



1.	What resolution do your people view the forms in?

2.	Which forms/reports are we talking about.  This will help me more rapidly

understanding what we are trying to do.

3.	Do you mind if I make some changes in your forms/reports.  I will

maintain the originals so if you do not care for the changes, we will be

able to modify the originals.



John Ruff - The Eternal Optimist :-)



-----Original Message-----

From: Pam McMillin [mailto:pmcmillin@m...]

Sent: Tuesday, March 27, 2001 7:06 AM

To: Access

Subject: [access] RE: Date Difference for Workdays Only



John,



You know I am just picking your brain on a regular basis.  Hope I am not

taking up too much of your time.  But I have another question.  I got this

procedure to work on my form, but I am needing it to show up on reports.

Also when I move to another record the user would have to click on the Run

Command each time.  Which isn't that big of a problem if I can get it to

show up on reports.



Any suggestions?



Pam

At 04:28 PM 3/26/2001 -0800, you wrote:





Pam,



Here's code you can use.  I created a form with three text boxex

(txtBeginDate, txtEndDate, txtDateDiff) and a command button (cmdRun).  On

the cmdRun_Click event I entered the following code.



Private Sub cmdRun_Click()

    Dim x As Integer



    ' I have the txtDateDiff set to 1 to

    ' account for the actual date in the txtBeginDate field

    txtDateDiff = 1



    ' The function DateDiff("d",txtBeginDate, txtEndDate) determines

    ' how many days are between the Begin Date and the End Date

    For x = 1 To DateDiff("d", txtBeginDate, txtEndDate)

        ' The Weekday function determines what day (1 thru 7) is being

evaluated

        ' The DateAdd function as 1 day to the txtBeginDate

        Select Case WeekDay(DateAdd("d", x, txtBeginDate))

            ' if the WeedDay function is not 1 and not 7 (Saturday, Sunday)

then add

            ' One to the txtDateDiff field on the for

            Case 2, 3, 4, 5, 6

                txtDateDiff = txtDateDiff + 1

        End Select

    Next x



End Sub










  Return to Index