I have some SQL code that will work if I put it in a query in MS Access, however, it will not work if I try to do it in VB6 as a string. Can anyone help me with this; I'd be greatly appreciative.

VB Code:
  1. '*INSERT()************************************************************************
  2. 'NAME: INSERT()
  3. 'DESC:  Inserts data from the TEST table and the PICKSL table into the MAIN table
  4. Private Sub insert()
  5.     Dim sql As String
  6.    
  7.     Set newConnection = New ADODB.connection
  8.     newConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
  9.         "Data Source= C:\Documents and Settings\p6b0438\My Documents\CycleCount Test\CycleCount\DB\cycleCount.mdb"
  10.     newConnection.Open
  11.        
  12.     sql = "INSERT INTO MAIN ( PICKSL, SLOT, RES, PROD, [DESC], PACK, " & _
  13.           "[MANU ID], HITIX, [PALLET ID], [PALLET QTY], DFP ) " & _
  14.           "SELECT t.PICKSL, t.SLOT, t.RES, t.PROD, t.DESC, t.PACK, " & _
  15.           "t.[MANU ID], t.HITIX, t.[PALLET ID], t.[PALLET QTY], t.DFP " & _
  16.           "FROM Test AS t " & _
  17.           "WHERE Not Exists ( " & _
  18.             "SELECT * " & _
  19.             "FROM [ALTER] a " & _
  20.             "WHERE  a.PROD = t.PROD);"
  21.  
  22.     newConnection.Execute (sql)
  23.    
  24.     sql = "INSERT INTO MAIN ( PICKSL, SLOT, PROD, [DESC], PACK, " & _
  25.           "[MANU ID], HITIX, [PALLET QTY] ) " & _
  26.           "SELECT p.PICKSL, p.PICKSL, p.PROD, p.DESC, p.PACK, " & _
  27.           "p.MANUID, p.HITI, p.OH " & _
  28.           "FROM PICKSL AS p " & _
  29.           "WHERE Not Exists ( " & _
  30.             "SELECT * " & _
  31.             "FROM [ALTER] a " & _
  32.             "WHERE  a.PROD = p.PROD);"
  33.  
  34.     newConnection.Execute (sql)
  35.    
  36.     newConnection.Close
  37.     Set newConnection = Nothing
  38. End Sub
  39. '*ENDOF*INSERT()***************************************************************