Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2003 update statement mis-behaving 1

Status
Not open for further replies.

vamoose

Programmer
Oct 16, 2005
320
MX
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
 
Replace this (2 times):
where (Priority <> 1) and (Core = '4x4') or (Core = '4X4')
wjth this:
where Priority <> 1 and Core = '4x4'

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top