Problem Setting A Field To Null

  • Thread starter Thread starter Corrine
  • Start date Start date
C

Corrine

AssignedEquipmentType and AssignedEquipment are text data type. Both are unique
five character codes. I have both fields in a continuous form. The database
requires that if an Equipment type is entered, an equipment item must also be
entered. I have the following code' to handle the case if AssignedEquipmentType
has been highlighted and deleted that AssignementEquipment must be set to Null.
When the code runs, I get error 3162 - You tried to assign the Null value to a
variable that isn't a Variant data type. Can someone help me to resolve the
problem.

Private Sub AssignedEquipmentType_AfterUpdate()
On Error GoTo ErrorHandler
If IsNull(Me!AssignedEquipmentType) Then
Me!AssignedEquipment = Null
Me!AssignedEquipmentType.SetFocus
Exit Sub
End If
End Sub

Thanks for your help!

Corrine
 
The error message suggests that Access is confused about what
"AssignmentEquipment" refers to. Do you have a field by this name? A text
box? Something else as well (e.g. a variable, or label, or ...)?

You could try something like this:

Private Sub AssignedEquipmentType_AfterUpdate()
If IsNull(Me!AssignedEquipmentType) And Not IsNull(Me.AssignedEquipment)
Then
Me!AssignedEquipment = Null
End If
End Sub
 
Back
Top