- Local time
- Today, 20:57
- Joined
- Sep 12, 2006
- Messages
- 16,072
I have 2 comboboxes to select a product no, and a unit of measurement
I have a materialprices table with unique records, keyed on productno and unitno, so i should get either one or no records returned from the following SQL
However, if i compare the values of the returned records with the search values and the tests, it shows a difference, although the difference is then showing as zero when I evaluate it.
(I found this because initially I had written the code using seek, and was trying to ensure I had located the correct record)
I have actually got round this by testing the abs difference as being greater than a minuscule value.
ie
If abs(rs!pmpprodno - cboProd)>0.01 Or abs(rs!pmpunit - cboUnit)>0.01 which does not produce an error
I could understand this if I was testing real numbers, but these are all integers - any ideas anyone?
so ignoring the dims - ignore any typos - the code compiles and executes properly - its just the equality test thats the problem
I have a materialprices table with unique records, keyed on productno and unitno, so i should get either one or no records returned from the following SQL
However, if i compare the values of the returned records with the search values and the tests, it shows a difference, although the difference is then showing as zero when I evaluate it.
(I found this because initially I had written the code using seek, and was trying to ensure I had located the correct record)
I have actually got round this by testing the abs difference as being greater than a minuscule value.
ie
If abs(rs!pmpprodno - cboProd)>0.01 Or abs(rs!pmpunit - cboUnit)>0.01 which does not produce an error
I could understand this if I was testing real numbers, but these are all integers - any ideas anyone?
so ignoring the dims - ignore any typos - the code compiles and executes properly - its just the equality test thats the problem
Code:
function lookupmat as boolean
strsql = "select * from tblmatprices where [pmpprodno] = " & cboProd & _
" and [pmpunit] = " & cboUnit
Set rs = CurrentDb.OpenRecordset(strsql)
If rs.eof Then
lookupmat = False
rs.Close
GoTo exitproc
End If
[COLOR="Blue"]'having used the above where clause to find an item, this test now seems to produce a difference, even though the figures are the same![/COLOR]
[COLOR="Red"] If rs!pmpprodno <> cboProd Or rs!pmpunit <> cboUnit Then[/COLOR] MsgBox ("Unexpected - There is a difference " & vbCrLf & _
"cboProd = " & Format(cboProd, "###.0000000000") & _
" Lookup = " & Format(rs!pmpprodno, "###.0000000000") & vbCrLf & _
"cboUnit = " & Format(cboUnit, "###.0000000000") & _
" Lookup = " & Format(rs!pmpunit, "###.0000000000") & vbCrLf)
[COLOR="Blue"]'and now both of these tests are showing a difference! of zero[/COLOR]
If cboProd <> rs!pmpprodno Then MsgBox ("Prod Was different " & cboProd - rs!pmpprodno)
If cboUnit <> rs!pmpunit Then MsgBox ("Unit Was different " & cboUnit - rs!pmpunit)
lookupmat = False
rs.Close
GoTo exitproc
End If
Last edited: