K
kontra
Hi again, you can disregard my previous post, I have modified code, now I am
just not sure how to loop though all the values in the tbl_Holidays and have
it in the fldHdate for this code to use.
******
Option Compare Database
Option Explicit
Public Function PreviousBD() As Date
Dim dbConn As ADODB.Connection ' Not sure if needed
Dim rsHolidays ' Should be coming from tbl_Holidays in current DB
Dim bdNum
Dim fldHdate As Date
bdNum = Weekday(Date)
Set rsHolidays = CurrentDb.OpenRecordset("SELECT [HDate] FROM tbl_Holidays",
dbOpenSnapshot)
'Not sure what parameters to use
fldHdate = rsHolidays.Fields.Item("HDate").Value
If bdNum = 2 And Date <> fldHdate Then
PreviousBD = Date - 3
If bdNum > 2 And Date - 1 = fldHdate Then
PreviousBD = Date - 2
If bdNum > 2 And Date - 1 <> fldHdate Then
PreviousBD = Date - 1
If bdNum = 3 And Date - 1 = fldHdate Then
PreviousBD = Date - 4
If bdNum = 2 And Date - 3 = fldHdate Then
PreviousBD = Date - 4
End If
End If
End If
End If
End If
Debug.Print bdNum
Debug.Print Date
Debug.Print fldHdate
Debug.Print PreviousBD
Set rsHolidays = Nothing
End Function
***********
I may be missing something else, Thanks for the help in advance.
just not sure how to loop though all the values in the tbl_Holidays and have
it in the fldHdate for this code to use.
******
Option Compare Database
Option Explicit
Public Function PreviousBD() As Date
Dim dbConn As ADODB.Connection ' Not sure if needed
Dim rsHolidays ' Should be coming from tbl_Holidays in current DB
Dim bdNum
Dim fldHdate As Date
bdNum = Weekday(Date)
Set rsHolidays = CurrentDb.OpenRecordset("SELECT [HDate] FROM tbl_Holidays",
dbOpenSnapshot)
'Not sure what parameters to use
fldHdate = rsHolidays.Fields.Item("HDate").Value
If bdNum = 2 And Date <> fldHdate Then
PreviousBD = Date - 3
If bdNum > 2 And Date - 1 = fldHdate Then
PreviousBD = Date - 2
If bdNum > 2 And Date - 1 <> fldHdate Then
PreviousBD = Date - 1
If bdNum = 3 And Date - 1 = fldHdate Then
PreviousBD = Date - 4
If bdNum = 2 And Date - 3 = fldHdate Then
PreviousBD = Date - 4
End If
End If
End If
End If
End If
Debug.Print bdNum
Debug.Print Date
Debug.Print fldHdate
Debug.Print PreviousBD
Set rsHolidays = Nothing
End Function
***********
I may be missing something else, Thanks for the help in advance.