Dim dbUPSWorld As DAO.Database
Dim dbTableForUPSImport As Database
Dim rsUPSWorld As DAO.Recordset
Dim rsTableForUPSImport As DAO.Recordset
Dim dbUSPS As DAO.Database
Dim rsUSPS As DAO.Recordset
Private Sub Add()
Set rsTableForUPSImport = dbTableForUPSImport.OpenRecordset("SELECT * FROM TableForUPSImport")
With rsTableForUPSImport
'Set it to Add mode
.AddNew
'Enter the field values
.Fields("void").Value = rsUPSWorld!void
.Fields("serv_type").Value = rsUPSWorld!serv_type
.Fields("billing_op").Value = rsUPSWorld!billing_op
.Fields("return_op").Value = rsUPSWorld!return_op
.Fields("return_typ").Value = rsUPSWorld!return_typ
.Fields("satdelop").Value = rsUPSWorld!satdelop
.Fields("satpickop").Value = rsUPSWorld!satpickop
.Fields("shipnot1op").Value = rsUPSWorld!shipnot1op
.Fields("shn1_type").Value = rsUPSWorld!shn1_type
.Fields("shn1_comp").Value = rsUPSWorld!shn1_comp
.Fields("shn1_cont").Value = rsUPSWorld!shn1_cont
.Fields("shn1_phone").Value = rsUPSWorld!shn1_phone
.Fields("shn1_fax").Value = rsUPSWorld!shn1_fax
.Fields("shn1_intlf").Value = rsUPSWorld!shn1_intlf
.Fields("shn1_memo").Value = rsUPSWorld!shn1_memo
.Fields("shipnot2op").Value = rsUPSWorld!shipnot2op
.Fields("shn2_type").Value = rsUPSWorld!shn2_type
.Fields("shn2_comp").Value = rsUPSWorld!shn2_comp
.Fields("shn2_cont").Value = rsUPSWorld!shn2_cont
.Fields("shn2_phone").Value = rsUPSWorld!shn2_phone
.Fields("shn2_fax").Value = rsUPSWorld!shn2_fax
.Fields("shn2_intlf").Value = rsUPSWorld!shn2_intlf
.Fields("shn2_memo").Value = rsUPSWorld!shn2_memo
.Fields("descofgood").Value = rsUPSWorld!descofgood
.Fields("doconlyind").Value = rsUPSWorld!doconlyind
.Fields("spec_inst").Value = rsUPSWorld!spec_inst
.Fields("to_id").Value = rsUPSWorld!to_id
.Fields("to_comp").Value = rsUPSWorld!to_comp
.Fields("to_attn").Value = rsUPSWorld!to_attn
.Fields("to_addr").Value = rsUPSWorld!to_addr
.Fields("to_addr2").Value = rsUPSWorld!to_addr2
.Fields("to_addr3").Value = rsUPSWorld!to_addr3
.Fields("to_country").Value = rsUPSWorld!to_country
.Fields("to_zip").Value = rsUPSWorld!to_zip
.Fields("to_city").Value = rsUPSWorld!to_city
.Fields("to_state").Value = rsUPSWorld!to_state
.Fields("to_phone").Value = rsUPSWorld!to_phone
.Fields("to_fax").Value = rsUPSWorld!to_fax
.Fields("to_taxid").Value = rsUPSWorld!to_taxid
.Fields("rec_upsnum").Value = rsUPSWorld!rec_upsnum
.Fields("loc_id").Value = rsUPSWorld!loc_id
.Fields("resind").Value = rsUPSWorld!resind
.Fields("pkg_type").Value = rsUPSWorld!pkg_type
.Fields("weight").Value = rsUPSWorld!Weight
.Fields("trackno").Value = rsUPSWorld!trackno
.Fields("oversize").Value = rsUPSWorld!oversize
.Fields("pkg_ref1").Value = rsUPSWorld!pkg_ref1
.Fields("pkg_ref2").Value = rsUPSWorld!pkg_ref2
.Fields("pkg_ref3").Value = rsUPSWorld!pkg_ref3
.Fields("pkg_ref4").Value = rsUPSWorld!pkg_ref4
.Fields("pkg_ref5").Value = rsUPSWorld!pkg_ref5
.Fields("addlhand").Value = rsUPSWorld!addlhand
.Fields("codopt").Value = rsUPSWorld!codopt
.Fields("codamount").Value = rsUPSWorld!codamount
.Fields("cashonly").Value = rsUPSWorld!cashonly
.Fields("declvalop").Value = rsUPSWorld!declvalop
.Fields("declvalam").Value = rsUPSWorld!declvalam
.Fields("delconfop").Value = rsUPSWorld!delconfop
.Fields("delconfsig").Value = rsUPSWorld!delconfsig
.Fields("hazmatop").Value = rsUPSWorld!hazmatop
.Fields("sn1op").Value = rsUPSWorld!sn1op
.Fields("sn1type").Value = rsUPSWorld!sn1type
.Fields("sn1comp").Value = rsUPSWorld!sn1comp
.Fields("sn1cont").Value = rsUPSWorld!sn1cont
.Fields("sn1phone").Value = rsUPSWorld!sn1phone
.Fields("sn1fax").Value = rsUPSWorld!sn1fax
.Fields("sn1intlf").Value = rsUPSWorld!sn1intlf
.Fields("sn1memo").Value = rsUPSWorld!sn1memo
.Fields("sn2op").Value = rsUPSWorld!sn2op
.Fields("sn2type").Value = rsUPSWorld!sn2type
.Fields("sn2comp").Value = rsUPSWorld!sn2comp
.Fields("sn2cont").Value = rsUPSWorld!sn2cont
.Fields("sn2phone").Value = rsUPSWorld!sn2phone
.Fields("sn2fax").Value = rsUPSWorld!sn2fax
.Fields("sn2intlf").Value = rsUPSWorld!sn2intlf
.Fields("sn2memo").Value = rsUPSWorld!sn2memo
.Fields("verbconfop").Value = rsUPSWorld!verbconfop
.Fields("verbcont").Value = rsUPSWorld!verbcont
.Fields("verbphone").Value = rsUPSWorld!verbphone
.Fields("length").Value = rsUPSWorld!length
.Fields("width").Value = rsUPSWorld!Width
.Fields("height").Value = rsUPSWorld!Height
.Fields("merchdesc").Value = rsUPSWorld!merchdesc
.Fields("date").Value = Format$(Date, "mm/dd/yyyy")
'Update it
.Update
'Close it
.Close
End With
End Sub
Private Sub Add2(MOMAll As String, TableMain As String)
Dim db As DAO.Database
Set db = DAO.DBEngine(0).OpenDatabase(MOMAll)
Set rsUSPS = dbUSPS.OpenRecordset("Select * FROM " & TableMain)
With rsUSPS
'Set it to Add mode
.AddNew
'Enter the field values
.Fields("void").Value = rsUPSWorld!void
.Fields("serv_type").Value = rsUPSWorld!serv_type
.Fields("billing_op").Value = rsUPSWorld!billing_op
.Fields("return_op").Value = rsUPSWorld!return_op
.Fields("return_typ").Value = rsUPSWorld!return_typ
.Fields("satdelop").Value = rsUPSWorld!satdelop
.Fields("satpickop").Value = rsUPSWorld!satpickop
.Fields("shipnot1op").Value = rsUPSWorld!shipnot1op
.Fields("shn1_type").Value = rsUPSWorld!shn1_type
.Fields("shn1_comp").Value = rsUPSWorld!shn1_comp
.Fields("shn1_cont").Value = rsUPSWorld!shn1_cont
.Fields("shn1_phone").Value = rsUPSWorld!shn1_phone
.Fields("shn1_fax").Value = rsUPSWorld!shn1_fax
.Fields("shn1_intlf").Value = rsUPSWorld!shn1_intlf
.Fields("shn1_memo").Value = rsUPSWorld!shn1_memo
.Fields("shipnot2op").Value = rsUPSWorld!shipnot2op
.Fields("shn2_type").Value = rsUPSWorld!shn2_type
.Fields("shn2_comp").Value = rsUPSWorld!shn2_comp
.Fields("shn2_cont").Value = rsUPSWorld!shn2_cont
.Fields("shn2_phone").Value = rsUPSWorld!shn2_phone
.Fields("shn2_fax").Value = rsUPSWorld!shn2_fax
.Fields("shn2_intlf").Value = rsUPSWorld!shn2_intlf
.Fields("shn2_memo").Value = rsUPSWorld!shn2_memo
.Fields("descofgood").Value = rsUPSWorld!descofgood
.Fields("doconlyind").Value = rsUPSWorld!doconlyind
.Fields("spec_inst").Value = rsUPSWorld!spec_inst
.Fields("to_id").Value = rsUPSWorld!to_id
.Fields("to_comp").Value = rsUPSWorld!to_comp
.Fields("to_attn").Value = rsUPSWorld!to_attn
.Fields("to_addr").Value = rsUPSWorld!to_addr
.Fields("to_addr2").Value = rsUPSWorld!to_addr2
.Fields("to_addr3").Value = rsUPSWorld!to_addr3
.Fields("to_country").Value = rsUPSWorld!to_country
.Fields("to_zip").Value = rsUPSWorld!to_zip
.Fields("to_city").Value = rsUPSWorld!to_city
.Fields("to_state").Value = rsUPSWorld!to_state
.Fields("to_phone").Value = rsUPSWorld!to_phone
.Fields("to_fax").Value = rsUPSWorld!to_fax
.Fields("to_taxid").Value = rsUPSWorld!to_taxid
.Fields("rec_upsnum").Value = rsUPSWorld!rec_upsnum
.Fields("loc_id").Value = rsUPSWorld!loc_id
.Fields("resind").Value = rsUPSWorld!resind
.Fields("pkg_type").Value = rsUPSWorld!pkg_type
.Fields("weight").Value = rsUPSWorld!Weight
.Fields("trackno").Value = rsUPSWorld!trackno
.Fields("oversize").Value = rsUPSWorld!oversize
.Fields("pkg_ref1").Value = rsUPSWorld!pkg_ref1
.Fields("pkg_ref2").Value = rsUPSWorld!pkg_ref2
.Fields("pkg_ref3").Value = rsUPSWorld!pkg_ref3
.Fields("pkg_ref4").Value = rsUPSWorld!pkg_ref4
.Fields("pkg_ref5").Value = rsUPSWorld!pkg_ref5
.Fields("addlhand").Value = rsUPSWorld!addlhand
.Fields("codopt").Value = rsUPSWorld!codopt
.Fields("codamount").Value = rsUPSWorld!codamount
.Fields("cashonly").Value = rsUPSWorld!cashonly
.Fields("declvalop").Value = rsUPSWorld!declvalop
.Fields("declvalam").Value = rsUPSWorld!declvalam
.Fields("delconfop").Value = rsUPSWorld!delconfop
.Fields("delconfsig").Value = rsUPSWorld!delconfsig
.Fields("hazmatop").Value = rsUPSWorld!hazmatop
.Fields("sn1op").Value = rsUPSWorld!sn1op
.Fields("sn1type").Value = rsUPSWorld!sn1type
.Fields("sn1comp").Value = rsUPSWorld!sn1comp
.Fields("sn1cont").Value = rsUPSWorld!sn1cont
.Fields("sn1phone").Value = rsUPSWorld!sn1phone
.Fields("sn1fax").Value = rsUPSWorld!sn1fax
.Fields("sn1intlf").Value = rsUPSWorld!sn1intlf
.Fields("sn1memo").Value = rsUPSWorld!sn1memo
.Fields("sn2op").Value = rsUPSWorld!sn2op
.Fields("sn2type").Value = rsUPSWorld!sn2type
.Fields("sn2comp").Value = rsUPSWorld!sn2comp
.Fields("sn2cont").Value = rsUPSWorld!sn2cont
.Fields("sn2phone").Value = rsUPSWorld!sn2phone
.Fields("sn2fax").Value = rsUPSWorld!sn2fax
.Fields("sn2intlf").Value = rsUPSWorld!sn2intlf
.Fields("sn2memo").Value = rsUPSWorld!sn2memo
.Fields("verbconfop").Value = rsUPSWorld!verbconfop
.Fields("verbcont").Value = rsUPSWorld!verbcont
.Fields("verbphone").Value = rsUPSWorld!verbphone
.Fields("length").Value = rsUPSWorld!length
.Fields("width").Value = rsUPSWorld!Width
.Fields("height").Value = rsUPSWorld!Height
.Fields("merchdesc").Value = rsUPSWorld!merchdesc
.Fields("date").Value = Format$(Date, "mm/dd/yyyy")
'Update it
.Update
'Close it
.Close
End With
Set db = Nothing
End Sub
Private Sub UpdateRecords()
Form1.Visible = True
Label1.Caption = "Updating records...."
Do While Not rsUPSWorld.EOF
Call Add
Call Add2 "G:\rabbitstop\UPS\UOWS\ImpExp\MOMImport.mdb", "USPS"
Call Add2 "G:\MOMAll.mdb", "ThreeCompanies"
rsUPSWorld.MoveNext
Loop
'Close upsworld.dbf
rsUPSWorld.Close
Set rsUPSWorld = Nothing
dbUPSWorld.Close
Set dbUPSWorld = Nothing
'rsTableForUPSImport.Close
Set rsTableForUPSImport = Nothing
'dbTableForUPSImport.Close
Set dbTableForUPSImport = Nothing
'rsUSPS.Close
Set rsUSPS = Nothing
'dbUSPS.Close
Set dbUSPS = Nothing
Label1.Caption = "Updating records....Done!"
Call Finish
End Sub
Private Sub Finish()
Call SetArchive
Timer1.Enabled = True
Timer2.Enabled = True
End Sub
Private Sub Timer1_Timer()
On Error GoTo errorhandler
Dim archive As Integer
archive = GetAttr("upsworld.dbf") And vbArchive
If archive = 32 Then
Timer1.Enabled = False
Set dbUPSWorld = OpenDatabase("MOMImport.mdb")
Set rsUPSWorld = dbUPSWorld.OpenRecordset("SELECT * FROM UPSWorld")
Set dbTableForUPSImport = OpenDatabase("MOMImport.mdb")
Set dbUSPS = OpenDatabase("MOMImport.mdb")
'Delete records that are 21 days old
dbUSPS.Execute ("USPSQuery")
dbTableForUPSImport.Execute ("DeleteQuery")
Set rsUSPS = dbUSPS.OpenRecordset("Select * FROM USPS")
Set rsTableForUPSImport = dbTableForUPSImport.OpenRecordset("SELECT * FROM TableForUPSImport")
Call UpdateRecords
End If
Exit Sub
errorhandler:
If Err.Number = 53 Then
MsgBox "file not found"
Else
MsgBox Err.Description, vbOKOnly, "Error"
End
End If
End Sub
Private Sub SetArchive()
On Error GoTo error_handler
Set fso = CreateObject("Scripting.FileSystemObject")
Set file = fso.GetFile("upsworld.dbf")
file.Attributes = 0
Exit Sub
error_handler:
MsgBox Err.Description, vbOKOnly, "Error"
End Sub
Private Sub Timer2_Timer()
Timer2.Enabled = False
Form1.Visible = False
Shell "temp.exe", vbNormalNoFocus
End
End Sub