'*ADD()************************************************************************
'NAME: add()
'DESC: Adds items that are not currently in the MAIN or ALTER table
Private Sub add()
On Error Resume Next
Set newConnection = New ADODB.connection
newConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source= C:\Documents and Settings\P6B0438\My Documents\Programs\Visual Basic\DB\Test.mdb"
newConnection.Open
Set newRecordSet = New ADODB.recordSet
newRecordSet.Open "Untitled", newConnection, adOpenKeyset, adLockPessimistic, adCmdTable
Set connection = New ADODB.connection
connection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source= C:\Documents and Settings\P6B0438\My Documents\Programs\Visual Basic\DB\cycleCount.mdb"
connection.Open
Set recordSet = New ADODB.recordSet
recordSet.Open "MAIN", connection, adOpenKeyset, adLockPessimistic, adCmdTable
Dim sql As String
newRecordSet.MoveFirst
Dim num As Integer
Do Until newRecordSet.EOF
If (inMain(newRecordSet.Fields("PICKSL"), newRecordSet.Fields("SLOT"), newRecordSet.Fields("RES"), newRecordSet.Fields("PROD"), newRecordSet.Fields("PACK"), newRecordSet.Fields("MANU ID"), newRecordSet.Fields("HITIX"), newRecordSet.Fields("PALLET ID"), newRecordSet.Fields("DFP")) = False) Then
MsgBox ("It's not in the MAIN table")
If (inAlter(newRecordSet.Fields("PICKSL"), newRecordSet.Fields("SLOT"), newRecordSet.Fields("RES"), newRecordSet.Fields("PROD"), newRecordSet.Fields("PACK"), newRecordSet.Fields("MANU ID"), newRecordSet.Fields("HITIX"), newRecordSet.Fields("PALLET ID"), newRecordSet.Fields("DFP")) = False) Then
MsgBox ("It's not in the ALTER table")
sql = "Insert into [MAIN] (PICKSL,SLOT,RES,PROD,[DESC],PACK," & _
"[MANU ID],HITIX, [PALLET ID],[PALLET QTY],DFP) VALUES ('" & _
recordSet.Fields("PICKSL") & "','" & recordSet.Fields("SLOT") & _
"','" & recordSet.Fields("RES") & "'," & recordSet.Fields("PROD") & _
",'" & recordSet.Fields("DESC") & "','" & recordSet.Fields("PACK") & _
"','" & recordSet.Fields("MANU ID") & "','" & recordSet.Fields("HITIX") & _
"','" & recordSet.Fields("PALLET ID") & "'," & recordSet.Fields("PALLET QTY") & _
",'" & recordSet.Fields("DFP") & "')"
Debug.Print sql
connection.Execute sql
Debug.Print sql
MsgBox ("Should have inserted")
End If
End If
newRecordSet.MoveNext
Loop
End Sub
'*ENDOF*ADD()******************************************************************