chaostheory
Registered User.
- Local time
- Today, 13:33
- Joined
- Sep 30, 2008
- Messages
- 69
Im not sure what happened but this module was written before my time with the company. And it has always run. I created a macro to run the module and a bunch of queries designed to update quantities in the database. For some reason the module has ceased to function. In order to make the module run in the macro i had to change it to a function (simply changed sub to public function). It ran for a few days just fine. One day i tried to run and i never got the usual "done" message. I went into the module itself and tried to run it, all i ever get is an hour glass for a second, then back to the blinking cursor. If i try to debug, i hit F8, same thing, hourglass, blinking cursor. If i insert a messagebox in the first line after the dim statement, it never pops up. Its completely dead. Any idea why, would it be a problem in the dim statement? and if it was shouldnt it tell me there is a syntax error?
Thanks for any help in advance, i dont like bugging my boss as shes a superemly busy hectic woman.
Thanks for any help in advance, i dont like bugging my boss as shes a superemly busy hectic woman.
Code:
Public Function autoupdate()
Dim ThisDB, SkidList, Qnt(1 To 12), Status(1 To 12), Size(1 To 10), RecCnt, Q, S, R, CurQnt As Integer, CurStatus, CurSize, Inspected
Dim SkidID
Set ThisDB = DBEngine.Workspaces(0).OpenDatabase("Z:\_AC_LBP\Database\03 Converted AC Tracking - Raw Data.mdb")
Set SkidList = ThisDB.OpenRecordset("Skid List", dbOpenTable)
Qnt(1) = "Green Qnt"
Qnt(2) = "1st Fire Qnt In"
Qnt(3) = "1st Fire Qnt Out"
Qnt(4) = "Slice Qnt In"
Qnt(5) = "Slice Qnt Out"
Qnt(6) = "Plug Qnt In"
Qnt(7) = "Plug Qnt Out"
Qnt(8) = "2nd Fire Qnt In"
Qnt(9) = "2nd Fire Qnt Out"
Qnt(10) = "C/S Qnt In"
Qnt(11) = "C/S Qnt Out"
Qnt(12) = "C/S Qnt Out"
Status(1) = "01 Green"
Status(2) = "02 In 1st Fire"
Status(3) = "03 1st Fired"
Status(4) = "04 In Slice"
Status(5) = "05 Sliced"
Status(6) = "06 In Plug"
Status(7) = "07 Plugged"
Status(8) = "08 In 2nd Fire"
Status(9) = "09 2nd Fired"
Status(10) = "10 In Contour/Skin"
Status(11) = "11 Contoured/Skinned"
Size(1) = "Extruded Size"
Size(2) = "Sliced Size"
Size(3) = "Finished Size"
Size(4) = "Finished Size"
Size(10) = "Potential Size"
RecCnt = SkidList.RecordCount
SkidList.MoveFirst
For R = 1 To RecCnt
SkidList.Edit
'SkidID = SkidList.Fields("Skid") 'debug
'If SkidList.Fields("Skid") Like "00320*" Then 'debug
'SkidID = SkidList.Fields("Skid")
'End If 'debug
For Q = 1 To 12
'TRIAL = SkidList.Fields(Qnt(Q)) 'dEBUG
If IsNull(SkidList.Fields(Qnt(Q))) = True Or Q = 12 Then
CurQnt = SkidList.Fields(Qnt(Q - 1))
If CurQnt = 0 Then
SkidList.Fields("Auto Status") = "Dead"
Else
SkidList.Fields("Auto Status") = Status(Q - 1)
End If
SkidList.Fields("Auto Cur Qnt") = CurQnt
Exit For
End If
Next Q
For S = 1 To 4
If IsNull(SkidList.Fields(Size(S))) = True Or S = 4 Then
If S = 2 And IsNull(SkidList.Fields(Size(10))) = False Then
CurSize = SkidList.Fields(Size(10))
Else
CurSize = SkidList.Fields(Size(S - 1))
End If
SkidList.Fields("Auto Cur\Pot Size") = CurSize
Exit For
End If
Next S
SkidID = SkidList.Fields("Skid")
Skid = "[Skid] = '" & SkidID & "'"
QntInspected = DCount("[Skid]", "Bare Characterization", Skid)
QntGone = DCount("[Order ID] & [If Reject, Defect]", "Bare Characterization", Skid)
QntLeft = QntInspected - QntGone
If QntInspected > 0 Then
If QntInspected = CurQnt Then
If QntLeft > 0 Then
SkidList.Fields("Auto Status") = "13 Inspected"
SkidList.Fields("Auto Cur Qnt") = QntLeft
Else
SkidList.Fields("Auto Status") = "Empty"
SkidList.Fields("Auto Cur Qnt") = QntLeft
End If
Else
SkidList.Fields("Auto Status") = "12 In Inspection"
SkidList.Fields("Auto Cur Qnt") = CurQnt - QntGone
End If
End If
SkidList.Update
SkidList.MoveNext
Next R
SkidList.Close
MsgBox ("Done!")
End Function