Using the following code to set priorities for assembly. The code is working fine up to priority #1 sttement but priority #2 statement is over-writing priority #1 and not selecting the next 16 records. Does anyone see any obvious mistakes. Thank you.
'4X4 count and set priorities
SQLa = "Select Count(Coil1) as FourXFour from Priority_Import where (Core = '4x4') or (Core = '4X4')": Set rs = conn.Execute(SQLa, , adCmdText)
FourXFour = rs.Fields("FourXFour").Value: White4X4 = Int(FourXFour / 3)
If White4X4 > 1 Then
DoCmd.RunSQL "Update [Select Top " & White4X4 & " Priority_Import.* from Priority_Import where (Core = '4x4') or (Core = '4X4')]. As a Set a.Priority = 1 where (Core = '4x4') or (Core = '4X4');"
End If
FourXFour = FourXFour - White4X4
If FourXFour >= White4X4 Then
DoCmd.RunSQL "Update [Select Top " & White4X4 & " Priority_Import.* from Priority_Import where (Priority <> 1) and (Core = '4x4') or (Core = '4X4')]. As a Set a.Priority = 2 where (Priority <> 1) and (Core = '4x4') or (Core = '4X4');"
End If
'4X4 count and set priorities
SQLa = "Select Count(Coil1) as FourXFour from Priority_Import where (Core = '4x4') or (Core = '4X4')": Set rs = conn.Execute(SQLa, , adCmdText)
FourXFour = rs.Fields("FourXFour").Value: White4X4 = Int(FourXFour / 3)
If White4X4 > 1 Then
DoCmd.RunSQL "Update [Select Top " & White4X4 & " Priority_Import.* from Priority_Import where (Core = '4x4') or (Core = '4X4')]. As a Set a.Priority = 1 where (Core = '4x4') or (Core = '4X4');"
End If
FourXFour = FourXFour - White4X4
If FourXFour >= White4X4 Then
DoCmd.RunSQL "Update [Select Top " & White4X4 & " Priority_Import.* from Priority_Import where (Priority <> 1) and (Core = '4x4') or (Core = '4X4')]. As a Set a.Priority = 2 where (Priority <> 1) and (Core = '4x4') or (Core = '4X4');"
End If