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.Templ ateID)=" & ID & "));"
Set rstDelete = db.OpenRecordset(strSQL)
If IsNull(Me.frmTemplateDetai lSub!Templ ateID) 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.
Set db = CurrentDb
strSQL = "SELECT * FROM qryTemplateDetail WHERE (((qryTemplateDetail.Templ
Set rstDelete = db.OpenRecordset(strSQL)
If IsNull(Me.frmTemplateDetai
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Partial solution
How is it partial?
Is there something missing or incorrect?
Is there something missing or incorrect?
ASKER