Hi I am new to VBA. I have got the follwing code which is working fi9. Now I want this code to check and ignore the bank holidays as well as it is excluding the saturday and sunday. how do i do it.
I Have got one table with fields, id (autonumber), pin no(text), date taken (date) and type (text). another table for Bank holidays with a single field, bank_holidays(date).
---------
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim dteIterator As Date
dteIterator = Me!StartDate
While dteIterator <= Me!EndDate
If Weekday(dteIterator, vbSunday) <> vbSaturday And _
Weekday(dteIterator, vbSunday) <> vbSunday Then
DoCmd.RunSQL "INSERT INTO tblMain([pin_No],[DateTaken], [Type]) VALUES ('" & _
Me!pin2 & "', #" & Format(dteIterator, "mm/dd/yyyy") & "#, '" & _
Me!type2 & "');"
End If
DoCmd.SetWarnings False
dteIterator = DateAdd("d", 1, dteIterator)
Wend
End Sub
I Have got one table with fields, id (autonumber), pin no(text), date taken (date) and type (text). another table for Bank holidays with a single field, bank_holidays(date).
---------
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim dteIterator As Date
dteIterator = Me!StartDate
While dteIterator <= Me!EndDate
If Weekday(dteIterator, vbSunday) <> vbSaturday And _
Weekday(dteIterator, vbSunday) <> vbSunday Then
DoCmd.RunSQL "INSERT INTO tblMain([pin_No],[DateTaken], [Type]) VALUES ('" & _
Me!pin2 & "', #" & Format(dteIterator, "mm/dd/yyyy") & "#, '" & _
Me!type2 & "');"
End If
DoCmd.SetWarnings False
dteIterator = DateAdd("d", 1, dteIterator)
Wend
End Sub