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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Complex algorithm - Misreading db?

Status
Not open for further replies.

Polariz666

Programmer
Jul 22, 2004
21
0
0
SE
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.
 
*Bump*

Rather desperate here :¬/ , any help at all welcomed.

Mike.
 
hmmmmmmmmmmmmmmmmmmmm ... mmm ... mmmm

No specific help from here. Only a cursory glance at the code and sample data, and the notation that both are somewhat incomplete for the purpose of analysis:

The sample data does not include any record with the erronoursly retrieved code ("17") so I would suggest looking into where (what record(s)) and their possib;e relation to the serial there might be.

The incompletion of the code is problematic mainly in two areas:

First, the declarations are missing, so it is not clear theat the various variables are, in fact, local to the snippet shown, or what other procedures (or even other parts of the one shown) might be manipulating the information. Second, we do not see the code which actually writes to the records, thus cannot see the 5W's of good reporting thus do not know relevant details of the record generation.

Finally, while not NECESSARILY a flaw, the aspect of multiple nested 'IF blocks' seems a bit contrived or awkward and at I would study this to see if some other structure would be clearer (e,g, select case?) for the 'human' interface.





MichaelRed
mlred@verizon.net

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top