[COLOR="Navy"]Sub[/COLOR] Foo()
[COLOR="Navy"]Dim[/COLOR] rs(1) [COLOR="Navy"]As[/COLOR] DAO.Recordset
[COLOR="Navy"]Dim[/COLOR] a(3) [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Variant[/COLOR]
[COLOR="Navy"]Dim[/COLOR] msg [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]String[/COLOR]
[COLOR="Navy"]Dim[/COLOR] ans [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Integer[/COLOR]
[COLOR="Navy"]Dim[/COLOR] blnFlag [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Boolean[/COLOR]
[COLOR="Navy"]Dim[/COLOR] i [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
msg = "Please back up the database first! " & vbNewLine & "Continue now?"
ans = MsgBox(msg, vbYesNo)
[COLOR="Navy"]If[/COLOR] ans <> vbYes [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]Exit[/COLOR] [COLOR="Navy"]Sub[/COLOR]
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]If[/COLOR]
[COLOR="Navy"]Set[/COLOR] rs(0) = CurrentDb.OpenRecordset("tblHistory", dbOpenTable)
[COLOR="Navy"]Set[/COLOR] rs(1) = CurrentDb.OpenRecordset("tblDestination", dbOpenTable)
[COLOR="Navy"]If[/COLOR] [COLOR="Navy"]Not[/COLOR] rs(0).EOF [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]With[/COLOR] rs(0)
[COLOR="Navy"]Do[/COLOR] [COLOR="Navy"]While[/COLOR] [COLOR="Navy"]Not[/COLOR] .EOF
a(0) = ![HistRev]
a(1) = ![MOrder]
a(2) = ![HistNotes]
a(3) = ![HistDate]
a(0) = Split(a(0), ";")
a(2) = Split(a(2), ";")
a(3) = Split(a(3), ";")
blnFlag = False
[COLOR="Navy"]If[/COLOR] UBound(a(0)) = UBound(a(2)) [COLOR="Navy"]And[/COLOR] UBound(a(0)) = UBound(a(3)) [COLOR="Navy"]Then[/COLOR]
blnFlag = True
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]If[/COLOR]
[COLOR="Navy"]If[/COLOR] blnFlag [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]With[/COLOR] rs(1)
[COLOR="Navy"]For[/COLOR] i = 0 [COLOR="Navy"]To[/COLOR] UBound(a(0))
.AddNew
![HistRev] = a(0)(i)
![MOrder] = a(1)
![HistNotes] = a(2)(i)
![HistDate] = a(3)(i)
.Update
[COLOR="Navy"]Next[/COLOR] i
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]With[/COLOR]
[COLOR="Navy"]Else[/COLOR]
MsgBox "Error: HistRev, HistNotes, and HistDate do not have the same number of elements."
[COLOR="Navy"]GoTo[/COLOR] My_Exit
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]If[/COLOR]
rs(0).MoveNext
[COLOR="Navy"]Loop[/COLOR]
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]With[/COLOR]
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]If[/COLOR]
rs(0).Close
rs(1).Close
[COLOR="Navy"]Set[/COLOR] rs(0) = [COLOR="Navy"]Nothing[/COLOR]
[COLOR="Navy"]Set[/COLOR] rs(1) = [COLOR="Navy"]Nothing[/COLOR]
MsgBox "Complete. "
My_Exit:
[COLOR="Navy"]On[/COLOR] [COLOR="Navy"]Error[/COLOR] [COLOR="Navy"]Resume[/COLOR] [COLOR="Navy"]Next[/COLOR]
[COLOR="Navy"]For[/COLOR] i = 0 [COLOR="Navy"]To[/COLOR] 1
[COLOR="Navy"]If[/COLOR] [COLOR="Navy"]Not[/COLOR] rs(i) [COLOR="Navy"]Is[/COLOR] [COLOR="Navy"]Nothing[/COLOR] [COLOR="Navy"]Then[/COLOR]
[COLOR="Navy"]If[/COLOR] rs(i).EditMode [COLOR="Navy"]Then[/COLOR]
rs(i).CancelUpdate
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]If[/COLOR]
rs(i).Close
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]If[/COLOR]
[COLOR="Navy"]Next[/COLOR] i
[COLOR="Navy"]Exit[/COLOR] [COLOR="Navy"]Sub[/COLOR]
errHandler:
MsgBox "Error " & Err.Number & ": " & Err.Description
[COLOR="Navy"]Resume[/COLOR] My_Exit
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]