休日の前営業日 | 備忘録 (。・_・。)ノ

Private Function getEigyoDate(dtParm As Date) As Date
    Set dbs = CurrentDb
    Do
        strSQL = "SELECT 非営業日 FROM カレンダー WHERE 非営業日 = #" & dtParm & "#"
        Set rst = dbs.OpenRecordset(strSQL)
        If rst.EOF = False Then
            dtParm = DateAdd("d", -1, dtParm)
            Debug.Print "日付=" & rst.Fields("非営業日") & " 前日=" & dtParm
        Else
            Exit Do
        End If
    Loop
    rst.Close
    dbs.Close
    Set rst = Nothing
    Set dbs = Nothing

    getEigyoDate = dtParm
End Function