Polariz666
Programmer
Hi all.
=========
Intro
=========
I'm having alot of trouble with an algorithm i've written, as it's producing odd results.
The program i'm writing sifts through a load of data about the testing of Boards. A Previous algorithm searches through a different set of records, tallying up which boards were good and which were bad - and on which production line. However we then look at the Par table, which only contains details about bad boards. Boards that fail are retested and given a rep code. If the rep code is not 0 then the board definitely failed. However if it is retested and passes on that particular test it is given a rep code of 0 and dubbed a 'false alarm'. If a serial is tested several times, and one of the tests ends in a fail, all other references to the board are ignored. If however we move on to the next board and the previous board still has the value 'badBoard = False' then the previous board was a FA, and we make the necesary adjustments to the bad/FA variables. Below is the code, sorry but it's quite complex:
=========
Code
=========
Set rs3 = New ADODB.Recordset
rs3.Open "SELECT * FROM Par WHERE Time LIKE '" & passDateToQueryField.Text & "%' ORDER BY Serial ASC", db2, adLockOptimistic
badBoard = False
While Not rs3.EOF
If lastSerial = "" Then
'This is the first record
lastSerial = rs3!Serial
If rs3!Rep <> "0" Then
'BAD BOARD - ignore all other references to serial
missNextProduct = True
rs3.MoveNext
badBoard = True
Else
'This board is a false alarm, move to next test
currentLine = rs3!stLine
rs3.MoveNext
End If
Else
'This is not the first record
If lastSerial = rs3!Serial And missNextProduct = True Then
'The product in hand is the same as before, and previous
'check made it a bad board
lastSerial = rs3!Serial
currentLine = rs3!stLine
rs3.MoveNext
Else
'Either it's a new board serial or the last check was a FA
If lastSerial <> rs3!Serial Then
'It's a new board
missNextProduct = False
'Check to see if the last board was bad. If it was,
'decrement/increment vars accordingly, then reset.
If badBoard = False Then
'The last board was a FA
dayOverallFA = dayOverallFA + 1
dayOverallBad = dayOverallBad - 1
If currentLine = "2" Then
dayLine2FA = dayLine2FA + 1
dayLine2Bad = dayLine2Bad - 1
ElseIf currentLine = "3" Then
dayLine3FA = dayLine3FA + 1
dayLine3Bad = dayLine3Bad - 1
End If
End If
badBoard = False
If rs3!Rep <> "0" Then
'BAD BOARD - ignore all other references to board
lastSerial = rs3!Serial
missNextProduct = True
currentLine = rs3!stLine
rs3.MoveNext
badBoard = True
Else
'This board is a false alarm, move to next Test
lastSerial = rs3!Serial
currentLine = rs3!stLine
rs3.MoveNext
End If
Else
'The last check was a FA - check this board
missNextProduct = False
If rs3!Rep <> "0" Then
'BAD BOARD - ignore all other references to serial
lastSerial = rs3!Serial
currentLine = rs3!stLine
missNextProduct = True
rs3.MoveNext
badBoard = True
Else
'This board is a false alarm, move to next test
lastSerial = rs3!Serial
currentLine = rs3!stLine
rs3.MoveNext
End If
End If
End If
End If
Wend
=========
Example data
=========
|Board|Time####|Serial|Rep|
|-------------------------|
|27900|20041210|123456|0 |
|27900|20041210|234567|0 |
|27900|20041210|345678|0 |
|27900|20041210|456789|0 |
|27900|20041210|456789|15 |
|27900|20041210|456789|0 |
|27900|20041210|567890|0 |
---------------------------
=========
The Problem
=========
Right. The problem is that the algorithm at some point goes wrong because the number of FA's are incorrect. I have breaked out and stepped into the program and found that for some reason when I get to the record 567890, it reads the rep code as '17' not '0'. I searched through the database and found only one record for 567890, and it's rep code was 0 (There are around 200,000 records). Any ideas? I appreciate that not many people are going to read through all this code (Though it's there if you want to), but any clues as to why my program would read the wrong info for the recordset?
Really appreciate any help,
Mike.
=========
Intro
=========
I'm having alot of trouble with an algorithm i've written, as it's producing odd results.
The program i'm writing sifts through a load of data about the testing of Boards. A Previous algorithm searches through a different set of records, tallying up which boards were good and which were bad - and on which production line. However we then look at the Par table, which only contains details about bad boards. Boards that fail are retested and given a rep code. If the rep code is not 0 then the board definitely failed. However if it is retested and passes on that particular test it is given a rep code of 0 and dubbed a 'false alarm'. If a serial is tested several times, and one of the tests ends in a fail, all other references to the board are ignored. If however we move on to the next board and the previous board still has the value 'badBoard = False' then the previous board was a FA, and we make the necesary adjustments to the bad/FA variables. Below is the code, sorry but it's quite complex:
=========
Code
=========
Set rs3 = New ADODB.Recordset
rs3.Open "SELECT * FROM Par WHERE Time LIKE '" & passDateToQueryField.Text & "%' ORDER BY Serial ASC", db2, adLockOptimistic
badBoard = False
While Not rs3.EOF
If lastSerial = "" Then
'This is the first record
lastSerial = rs3!Serial
If rs3!Rep <> "0" Then
'BAD BOARD - ignore all other references to serial
missNextProduct = True
rs3.MoveNext
badBoard = True
Else
'This board is a false alarm, move to next test
currentLine = rs3!stLine
rs3.MoveNext
End If
Else
'This is not the first record
If lastSerial = rs3!Serial And missNextProduct = True Then
'The product in hand is the same as before, and previous
'check made it a bad board
lastSerial = rs3!Serial
currentLine = rs3!stLine
rs3.MoveNext
Else
'Either it's a new board serial or the last check was a FA
If lastSerial <> rs3!Serial Then
'It's a new board
missNextProduct = False
'Check to see if the last board was bad. If it was,
'decrement/increment vars accordingly, then reset.
If badBoard = False Then
'The last board was a FA
dayOverallFA = dayOverallFA + 1
dayOverallBad = dayOverallBad - 1
If currentLine = "2" Then
dayLine2FA = dayLine2FA + 1
dayLine2Bad = dayLine2Bad - 1
ElseIf currentLine = "3" Then
dayLine3FA = dayLine3FA + 1
dayLine3Bad = dayLine3Bad - 1
End If
End If
badBoard = False
If rs3!Rep <> "0" Then
'BAD BOARD - ignore all other references to board
lastSerial = rs3!Serial
missNextProduct = True
currentLine = rs3!stLine
rs3.MoveNext
badBoard = True
Else
'This board is a false alarm, move to next Test
lastSerial = rs3!Serial
currentLine = rs3!stLine
rs3.MoveNext
End If
Else
'The last check was a FA - check this board
missNextProduct = False
If rs3!Rep <> "0" Then
'BAD BOARD - ignore all other references to serial
lastSerial = rs3!Serial
currentLine = rs3!stLine
missNextProduct = True
rs3.MoveNext
badBoard = True
Else
'This board is a false alarm, move to next test
lastSerial = rs3!Serial
currentLine = rs3!stLine
rs3.MoveNext
End If
End If
End If
End If
Wend
=========
Example data
=========
|Board|Time####|Serial|Rep|
|-------------------------|
|27900|20041210|123456|0 |
|27900|20041210|234567|0 |
|27900|20041210|345678|0 |
|27900|20041210|456789|0 |
|27900|20041210|456789|15 |
|27900|20041210|456789|0 |
|27900|20041210|567890|0 |
---------------------------
=========
The Problem
=========
Right. The problem is that the algorithm at some point goes wrong because the number of FA's are incorrect. I have breaked out and stepped into the program and found that for some reason when I get to the record 567890, it reads the rep code as '17' not '0'. I searched through the database and found only one record for 567890, and it's rep code was 0 (There are around 200,000 records). Any ideas? I appreciate that not many people are going to read through all this code (Though it's there if you want to), but any clues as to why my program would read the wrong info for the recordset?
Really appreciate any help,
Mike.