Link to home
Start Free TrialLog in
Avatar of skennelly
skennelly

asked on

Data Type Conversion Error with Empty String

I would like to delete the value of a Number field (ExerciseID) for a selected group of records in code. In the following code the ExerciseID is Number field. I get the following error when run the code: "Run Time Error: Data Type Conversion Error."

Set db = CurrentDb
strSQL = "SELECT * FROM qryTemplateDetail WHERE (((qryTemplateDetail.TemplateID)=" & ID & "));"

Set rstDelete = db.OpenRecordset(strSQL)
If IsNull(Me.frmTemplateDetailSub!TemplateID) Then
    DisplayMessage ("There are no records to delete.")
    Exit Sub
Else
    Do While Not rstDelete.EOF
       With rstDelete
            .Edit
            !ExerciseID = ""
            .Update
       End With
    rstDelete.MoveNext
    Loop
End If

If I change the "" to Null, (ie. !ExerciseID = Null), during the next sequence of code I get the following error: "You tried to assign the Null variable that is not a Variant data type."

Is there a way around this? Could I change the Number data type to a Variant on the fly? Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Norie
Norie

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of skennelly
skennelly

ASKER

I will try the update query and let you know. Thanks.
Partial solution
How is it partial?

Is there something missing or incorrect?