By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,967 Members | 1,178 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,967 IT Pros & Developers. It's quick & easy.

Problem Setting A Field To Null

P: n/a
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
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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

--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Corrine" <cm****@earthlink.net> wrote in message
news:5n****************@newsread2.news.atl.earthli nk.net...
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

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.