I’ve built a production schedule in Excel spread sheet that need to pull MO data into this spread sheet. Three views of MIMOH, MIMOMD, OEORDH are involved in data exporting. This program worked fine in all other aspects. The problem is that as long as I started to run this program, our ACCPAC system became very instable as result of Data corrupting quite often, and recover process was really pain on.
Actually, I used “Set xxxxx=nothing “ to release all the references to ACCPAC at the end of VB code. Even though I completely closed Excel application, when I checked in our server, it show that many ACCPAC objects DLL were referenced under my name. All references could be removed until I shut down my computer. I know that some administrator processes in accpac need every user logging off from accpac and my program for some reasons was putting a hook on accpac in the background. I wonder someone could help me to figure out either error within my code or accpac setup issue, right now I manually did all data entry for our production schedule. Main portion of the code is attached as following(not runnable as data manipulate code is excluded).
Thank you very much in advance.
Private Session As ACCPACXAPILib.xapiSession
Private Company As ACCPACXAPILib.xapiCompany
Private viewOEORDH As xapiView
Private viewMIMOH As xapiView
Private viewMIMOMD As xapiView
Public Sub ExportMoToSh()
'.......
Set Session = CreateObject("ACCPAC.xapisession")
Session.Open AccpacUseName, AccapacPassword, "DNADAT", Date, 0
Set viewOEORDH = Session.OpenView("OE0520", "OE")
Set viewMIMOH = Session.OpenView("MI0046", "MI")
Set viewMIMOMD = Session.OpenView("MI0047", "MI")
With viewMIMOH
strBrowse = "(WOHID>" & MaxMoInSchd & ") AND (WOHID<2)"
.Order = 1
.Browse strBrowse, True
Do While .Fetch
'export data from header.......
With viewMIMOMD
.Order = 1
.Init
strBrowseD = "(" & "WOHID" & "=" & Trim(viewMIMOH.Fields("WOHID").Value) & ")AND(" & "ITEM" & "=" & """LBLAB""" & ")"
.Browse strBrowseD, True
Do While .Fetch
'export data from detail........
loop
End With
With viewOEORDH
.Order = 1
strBrowseOED = "ORDNUMBER" & "=" & Trim(viewMIMOH.Fields("DESCR").Value)
.Init
.Browse strBrowseOED, True
.Fetch
'export data from OE header.........
End With
Loop
End with
EndPoint:
Set viewOEORDH = Nothing
Set viewMIMOH = Nothing
Set viewMIMOMD = Nothing
Set Session = Nothing
End Sub
Actually, I used “Set xxxxx=nothing “ to release all the references to ACCPAC at the end of VB code. Even though I completely closed Excel application, when I checked in our server, it show that many ACCPAC objects DLL were referenced under my name. All references could be removed until I shut down my computer. I know that some administrator processes in accpac need every user logging off from accpac and my program for some reasons was putting a hook on accpac in the background. I wonder someone could help me to figure out either error within my code or accpac setup issue, right now I manually did all data entry for our production schedule. Main portion of the code is attached as following(not runnable as data manipulate code is excluded).
Thank you very much in advance.
Private Session As ACCPACXAPILib.xapiSession
Private Company As ACCPACXAPILib.xapiCompany
Private viewOEORDH As xapiView
Private viewMIMOH As xapiView
Private viewMIMOMD As xapiView
Public Sub ExportMoToSh()
'.......
Set Session = CreateObject("ACCPAC.xapisession")
Session.Open AccpacUseName, AccapacPassword, "DNADAT", Date, 0
Set viewOEORDH = Session.OpenView("OE0520", "OE")
Set viewMIMOH = Session.OpenView("MI0046", "MI")
Set viewMIMOMD = Session.OpenView("MI0047", "MI")
With viewMIMOH
strBrowse = "(WOHID>" & MaxMoInSchd & ") AND (WOHID<2)"
.Order = 1
.Browse strBrowse, True
Do While .Fetch
'export data from header.......
With viewMIMOMD
.Order = 1
.Init
strBrowseD = "(" & "WOHID" & "=" & Trim(viewMIMOH.Fields("WOHID").Value) & ")AND(" & "ITEM" & "=" & """LBLAB""" & ")"
.Browse strBrowseD, True
Do While .Fetch
'export data from detail........
loop
End With
With viewOEORDH
.Order = 1
strBrowseOED = "ORDNUMBER" & "=" & Trim(viewMIMOH.Fields("DESCR").Value)
.Init
.Browse strBrowseOED, True
.Fetch
'export data from OE header.........
End With
Loop
End with
EndPoint:
Set viewOEORDH = Nothing
Set viewMIMOH = Nothing
Set viewMIMOMD = Nothing
Set Session = Nothing
End Sub