Help with access 97 application

K

Kclark

I have inherited an access 97 application. It has various
problems that I am trying to fix. The following code is
causing some problems when bad data is stored in the
Glucose field. instead of a numeric value Note: is stored
in it, therefore I receive a type mismatch error. Any
ideas on a solution would be greatly appreciated.

Do Until myLabTest.EOF
If GlycohemoglobinValue = False Then
If Right(myLabTest!GLYHGB, 4) > 9 Or Right
(myLabTest!GLUCOSE, 3) >= 140 Then
GlycohemoglobinValue = True
End If
End If
myLabTest.MoveNext
Loop
 
G

Gary Miller

It looks like you are doing a numeric comparison on a field
that is actually text. If the problem value is always
'Note:' then you could add another IF statement before you
do your numerical comparison to see if the value is Note:
and handle the problem that way or you could test your Right
statement to see if that is numerical. Here is the first
method...

Do Until myLabTest.EOF
If GlycohemoglobinValue = False Then
If myLabTest!GLYHGB = "Note:" Or
myLabTest!GLUCOSE = "Note:" Then
' Do whatever you need here to handle
the problem
Else

If Right(myLabTest!GLYHGB, 4) > 9 Or Right
( myLabTest!GLUCOSE, 3) >= 140 Then
GlycohemoglobinValue = True
End If
End If
myLabTest.MoveNext
Loop

--

Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
 
G

Guest

Thanks for you help. The value is not always "Note:" Can
I just do a IsNumeric function on the Glucose?

like this:

If Right(myLabTest!GLYHGB, 4) > 9 Or IsNumeric(Right
 
C

cTaHk0

Look for Cint() function if part of string value is an integer or Csng() if
in value you expecting is a decimal number

csng(Right("ABC4445.55", 4))

result = 5.55

regards,

cTaHk0

If Len(Right(myLabTest!GLYHGB, 4)) > 9
 
G

Guest

Thanks for your help.

using Cint() I still receive the Type mismatch error when
it finds any data that does not contain an integer.
ie "Note:"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top