Having a small problem that I cannot seem to figure out.
I'm calling a function whose variables are all optional, and when I don't feed it the first variable, it thinks that I've actually fed it the variable. So my IsMissing() statements are returning false when they should be true! Let me explain through a little bit of the code - this is not the entire routine.
Code:
'Procedure calls the subroutine
Sub TEST()
LogError , , "Work", "Please", , ""
End Sub
'Open, and where the error occurs
Sub LogError(Optional errX As ErrObject, Optional LineNum As Long, Optional strProcName As String, Optional FieldValue As String, Optional FieldValue2 As String, Optional FieldValue3 As String, Optional FieldValue4 As String)
If IsMissing(errX) = False Then
' Store error information.
' Clear error.
strErrText = errX.Description
lngErrNum = errX.Number
errX.Clear
End If
Everytime it runs the code inside the If Then STatement even though it shouldn't since I'm not feeding it a value for errX. The IsMissing should return as True, and it should skip the code. I've tried it all different ways, if it's true, else statments, etc..
When I stop the code during it's runtime, and hold the mouse over Optional errX As ErrObject it shows "errX=Nothing". So is it assinging the value Nothing to my Optional variable... I've tried replacing IsMissing with If errX = Nothing ... and that doesn't work either.
-Josh
------------------
-JPeters
Got a helpful tip for Access Users? Check out and contribute to 'How to Keep Your Databases from becoming Overwhelming!'
thread181-293590
jpeters@guidemail.com
------------------
I'm calling a function whose variables are all optional, and when I don't feed it the first variable, it thinks that I've actually fed it the variable. So my IsMissing() statements are returning false when they should be true! Let me explain through a little bit of the code - this is not the entire routine.
Code:
'Procedure calls the subroutine
Sub TEST()
LogError , , "Work", "Please", , ""
End Sub
'Open, and where the error occurs
Sub LogError(Optional errX As ErrObject, Optional LineNum As Long, Optional strProcName As String, Optional FieldValue As String, Optional FieldValue2 As String, Optional FieldValue3 As String, Optional FieldValue4 As String)
If IsMissing(errX) = False Then
' Store error information.
' Clear error.
strErrText = errX.Description
lngErrNum = errX.Number
errX.Clear
End If
Everytime it runs the code inside the If Then STatement even though it shouldn't since I'm not feeding it a value for errX. The IsMissing should return as True, and it should skip the code. I've tried it all different ways, if it's true, else statments, etc..
When I stop the code during it's runtime, and hold the mouse over Optional errX As ErrObject it shows "errX=Nothing". So is it assinging the value Nothing to my Optional variable... I've tried replacing IsMissing with If errX = Nothing ... and that doesn't work either.
-Josh
------------------
-JPeters
Got a helpful tip for Access Users? Check out and contribute to 'How to Keep Your Databases from becoming Overwhelming!'
thread181-293590
jpeters@guidemail.com
------------------