テーブルから検索
Dim ary開始日(0 To 4) As Date
Dim ary元号(0 To 4) As String
Dim intCount As Integer
intCount = 0
Dim objRecordset As DAO.Recordset
Dim strSql As String
strSql = _
"SELECT " & _
" 開始日 " & _
" ,元号 " & _
"FROM " & _
" tblJapaneseEra " & _
"ORDER BY " & _
" 開始日 DESC;"
Set objRecordset = Application.CurrentDb.OpenRecordset(strSql)
Do Until objRecordset.EOF
ary開始日(intCount) = objRecordset("開始日").Value
ary元号(intCount) = objRecordset("元号").Value
intCount = intCount + 1
objRecordset.MoveNext
Loop
objRecordset.Close
Debug.Print (ary開始日(0))
和暦から西暦を取得する
Public Function JapaneseEraToYear(strLocalEra As String, intLocalEra) As Integer
Dim datStart As Date
datStart = DLookup("開始日", "tblJapaneseEra", "元号='" & strLocalEra & "'")
JapaneseEraToYear = Year(datStart) + intLocalEra - 1
End Function
IsDateCustom