Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 97 coding

Status
Not open for further replies.

darronb

Technical User
Feb 8, 2002
67
0
0
GB
Hi

I wonder if anyone can help me.

I have an Access 97 database, with a date field in it. I have to come up with some code that will find the amount of "work" days (Monday to Friday) between this date and todays date and then take one off that number.

I have not realy done any code on access, but i have done some in Excel.

can anyone help

Thanks
 
Thanks for that, I have now Put the code together, See below

My only problem now is how do i get it to apply to a specific colmun in a table. the below code works fine as a one shot test.

Private Sub Day_Calc_Click()

Dim startdate As Date
Dim today As Date
'Dim RELOGDATE As Date
Dim relogdates As Date
Dim DateDiffW As Integer

Me.Refresh

today = Now()
today = UCase(Left(today, 10))
relogdates = RELOGDATE.Value

Const SUNDAY = 1
Const SATURDAY = 7
Dim NumWeeks As Integer

If relogdates > today Then
DateDiffW = 0
Else
Select Case WeekDay(relogdates)
Case SUNDAY: relogdates = relogdates + 1
Case SATURDAY: relogdates = relogdates + 2
End Select
Select Case WeekDay(today)
Case SUNDAY: today = today - 2
Case SATURDAY: today = today - 1
End Select
NumWeeks = DateDiff("ww", relogdates, today)
DateDiffW = NumWeeks * 5 + WeekDay(today) - WeekDay(relogdates)
End If

RELOGDAYS.Value = DateDiffW
 
You have to know how to create a function returning a value depending of parameter(s) ...
 
Great, Thanks for that, I have now got the value coming out of the function.

Could you now please point me in the right direction on how to populate a colmun in a table.

Sorry for being a Numpty but I am an amature at this.

Thanks for all your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top