Error 3162 - null value / not a variant

G

Guest

I have a misbehaving bound combo box on a form. The field to which it is
bound is neither required nor part of the primary key in the table, yet the
form generates a 3162 error ("You tried to assign the Null value to a
variable that is not a Variant data type") when I clear the value, whether
manually or programmatically.

Other reasons for 3162?

In addition, the PK of the table to which the form is bound consists of 4
fields. Curiously, I get the 3162 when deleting the value from any of the
three non-date controls, but not when I clear the value of the one
date-formatted control/field that is part of the PK.
 
G

Guest

Well, I figured out the problem. The RecordSource of the form includes
(equal) joins to other tables on the fields in quesion (for record-sorting
purposes).

Since my concern regarding the Null values in the first place was only that
I needed to provide a way to handle the Nulls, that just becomes one job I do
not need to do for those controls on this form.
 
D

Douglas J. Steele

It sounds as though somewhere in code, you're assigning the value of the
control to a variable.
 
G

Guest

Thanks, Douglas. That was my first thought, but look at my 2nd post. I had
the form's record source joined to another table so I could sort on fields
from the joined tables.

I removed the join temporarily and poof - problem gone. While I would still
have liked the ability to re-nullify that field, I understand the logic
inherent in the equal join, and in the end, all I was trying to do was to
handle nulls in the control's before/after update. Since there cannot be any
nulls as the result of an update in this case, it's just less code I have to
write.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top