Type Mismatch Error

L

LeAnn

I have an Access 2000 database. On one of my forms (bound to query) I have 2
date fields that the users can edit. When the user clicks SAVE, it calls a
validation procedure that checks a number of criteria for valid dates. In
that procedure there are 2 string variables declared and set to the date
controls using another procedure that assigns a nullstring if the control is
empty:

strTDate = Nullstring(Me.ThawDte) ‘set variable early in main procedure

******************
‘Nullstring function statements
If IsNull(varNull) Then
NullString = ""
Else
NullString = CStr(varNull)
End If
******************
Later in the validation procedure but fairly early there is:

If strTDate <> ҠThen
More validation statements

I’m getting a type mismatch error on the IF statement when the user clears
the control to delete the value and then clicks save.

I’ve stepped through the procedure and the variable is set to “â€.

The procedure works fine if the user wants to edit the other date and this
control is already empty. Is there something about “clearing†the control
that is causing the problem?

Any ideas?
Thanks LeAnn
 
L

LeAnn

I have read many posts related to this error and found a couple of possible
solutions using Not isNull(control) AND/OR vbNullString for the IF statement
and I still get the error.
 
J

John Vinson

When the user clicks SAVE, it calls a
validation procedure that checks a number of criteria for valid dates.

Umm...

You're going to a LOT of extra work.

If Not IsDate(Me!txtDatefield) Then
<warn the user that it's not a valid date>
End If

John W. Vinson[MVP]
 
Top