Re: Troubleshooting error in VB 6.0
- From: "WB" <none>
- Date: Wed, 15 Nov 2006 11:49:41 -0800
Thank you for the informative response.
I do understand the error 94 and the reason it is being thrown. The problem
is it isn't consistent. For example, when the error is thrown and the user
clicks "OK" they have been instructed to delete the transaction they were
entering and re-enter it. When it is re-entered no error is thrown and the
information is saved correctly. Nothing changes from one entry to the next.
the error is random and at some locations it is more prevalent than others.
I will have to look at how the error handlers are organized and written more
closely to ensure that when the actual code causing the error is executed it
is being trapped. To compound the problem and difficulty resolving it, I
place a call to write a line of text to the test file before the saving of
the data and after the saving of the data. Then a few more lines of code
are executed, none of which are writing to the database. That is when the
error happens.
WB
"MikeD" <nobody@xxxxxxxxxxx> wrote in message
news:%23H1DhaECHHA.4348@xxxxxxxxxxxxxxxxxxxxxxx
(away
"WB" <none> wrote in message news:eWx4oDDCHHA.3380@xxxxxxxxxxxxxxxxxxxxxxx
I have an application designed in VB6.0. I am being told from users
happening.from development office) that an error is being generated (error 94). I
placed some logging code in the application to write test lines out to a
text file so I can pinpoint exactly why and where the error is
haveThe problem is the error being generated doesn't occur or match the test
lines being written to the text file. I am trying to get answer to this
question.
Error number 94 is Invalid use of Null. Chances are, you're reading data
from a database into a recordset, and when going through the recordset,
you're attempting to assign the field's value to a string variable or
perhaps a textbox (or anything that can only accept a string).
If the data type of the FIELD is a string type, one common way of dealing
with the possibility of it being null is just concatenating a 0-length
string (or you can preprend it as well). Like this:
sData = oRS.Fields("MyField").Value & ""
Alternatively, use the IsNull function to check it:
If IsNull(oRS.Fields("MyField").Value Then
sData = ""
Else
sData = oRS.Fields("MyField").Value
End If
You have to use IsNull for non-string types. For example, this WON'T work:
Dim lData As Long
lData = oRS.Fields("MyField").Value & ""
(You'll get the invalid use of Null error)
Is it possible for lines of code to execute without a resume next
or any other "trapping", and the error to display after several lines
beexecuted beyond the actual error?
Not sure I understand the question entirely, but I guess the answer would
yes. Among others, one way you could have this situation is if you call aDOES
function that doesn't have it's own local error from a procedure which
have a local and active error handler. Just for an extremely simple (andchanged
admittedly poor) example:
Option Explicit
Private Sub ShowRemainder(ByVal Divisor As Long, ByVal Dividend As Long)
Dim lRemainder As Long
lRemainder = Divisor Mod Dividend
MsgBox lRemainder
End Sub
Private Sub Form_Click()
On Error GoTo EH
ShowRemainder 10, 0
'just some code that won't ever execute unless the above line is
'such that 0 is not passed for the Dividend parameter.the
Me.Move 500, 500
EH:
MsgBox Err.Description
End Sub
(Hmm, looking at that, did I get Divisor and Dividend right? Divisor is
number "on top", right? <g>)
--
Mike
Microsoft MVP Visual Basic
.
- Follow-Ups:
- Re: Troubleshooting error in VB 6.0
- From: MikeD
- Re: Troubleshooting error in VB 6.0
- References:
- Troubleshooting error in VB 6.0
- From: WB
- Re: Troubleshooting error in VB 6.0
- From: MikeD
- Troubleshooting error in VB 6.0
- Prev by Date: Re: Error 451
- Next by Date: Convert datestring to date with specified format
- Previous by thread: Re: Troubleshooting error in VB 6.0
- Next by thread: Re: Troubleshooting error in VB 6.0
- Index(es):
Relevant Pages
|