'CHECKZEROOH()*****************************************************************
Private Function checkZeroOH(PICKSL As String, PROD As Long, DESC As String) As Boolean
Dim sql As String
Set otherConnection = New ADODB.connection
otherConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source= G:\Finance\Inventory Control\CycleCount\DB\Z028.mdb"
otherConnection.Open
Set otherRecordset = New ADODB.recordSet
sql = "SELECT [OH] FROM [Untitled] WHERE [PICKSL]='" & PICKSL & "' and [PROD]=" & PROD & " and [DESC]='" & DESC & "'"
otherRecordset.Open sql, otherConnection, adOpenKeyset, adLockPessimistic, adCmdText
If (sql = "0" Or sql = "") Then
'The PICK SLOT is zero
checkZeroOH = True
Exit Function
End If
checkZeroOH = False
End Function
'ENDOF*CHECKZEROOH()***********************************************************
'ADDZEROOH()*******************************************************************
Private Sub addZeroOH(PICKSL As String, PROD As Long, DESC As String, MANUID As String, HITI As String, OH As Integer)
Dim sql As String
Set newConnection = New ADODB.connection
newConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source= G:\Finance\Inventory Control\CycleCount\DB\CycleCount.mdb"
newConnection.Open
Set newRecordSet = New ADODB.recordSet
sql = "Insert into [MAIN] (PICKSL,SLOT,RES,PROD,[DESC],PACK," & _
"[MANU ID],HITIX, [PALLET ID],[PALLET QTY],DFP) VALUES ('" & _
PICKSL & "','',''," & PROD & ",'" & DESC & "','','" & MANUID & "','" & HITI & _
"',''," & OH & ",''"
MsgBox (sql)
newConnection.Execute sql
sql = "Insert into [ALTER] (USERNAME,DATEOFCHANGE," & _
"TYPEOFCHANGE,PICKSL,SLOT,RES,PROD,[DESC],PACK," & _
"[MANU ID],HITIX, [PALLET ID],[PALLET QTY],DFP) VALUES (" & _
"'p6b0438',#" & Now() & "#," & "'ZERO OH ADDED','" & _
PICKSL & "','',''," & PROD & ",'" & DESC & "','','" & MANUID & "','" & HITI & _
"',''," & OH & ",''"
MsgBox (sql)
newConnection.Execute sql
newRecordSet.Close
newConnection.Close
Set newRecordSet = Nothing
Set newConnection = Nothing
End Sub
'ENDOF*ADDZEROOH()*************************************************************
'LOOPTHRUZEROOH()**************************************************************
Private Sub loopThruZeroOH()
Set connection = New ADODB.connection
connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source= G:\Finance\Inventory Control\CycleCount\DB\Z028.mdb"
connection.Open
Set recordSet = New ADODB.recordSet
recordSet.Open "Untitled", connection, adOpenKeyset, adLockPessimistic, adCmdTable
recordSet.MoveFirst
Do Until recordSet.EOF
If (checkZeroOH(recordSet.Fields("PICKSL"), recordSet.Fields("PROD"), _
recordSet.Fields("DESC")) = True) Then
'////THE ERROR IS ON THE NEXT LINE ///////////////////////////////////
addZeroOH(recordset.Fields("PICKSL"), _
recordset.Fields("PROD"), _
recordset.Fields("DESC"), _
recordset.Fields("MANUID"), _
recordset.Fields("HITI"), _
recordset.Fields("OH"))
addZeroOH(recordSet.Fields("PICKSL"), recordSet.Fields("PROD"), _
recordSet.Fields("DESC"), recordSet.Fields("MANUID"), _
recordSet.Fields("HITI"), recordSet.Fields("OH"))
End If
recordSet.MoveNext
Loop
End Sub
'ENDOF*LOOPTHRUZEROOH()********************************************************