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.
Brian - 10 Jun 2007 22:40 GMT
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.
> 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
[quoted text clipped - 8 lines]
> three non-date controls, but not when I clear the value of the one
> date-formatted control/field that is part of the PK.
Douglas J. Steele - 10 Jun 2007 22:43 GMT
It sounds as though somewhere in code, you're assigning the value of the
control to a variable.

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)
>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
[quoted text clipped - 9 lines]
> three non-date controls, but not when I clear the value of the one
> date-formatted control/field that is part of the PK.
Brian - 11 Jun 2007 00:48 GMT
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.
> It sounds as though somewhere in code, you're assigning the value of the
> control to a variable.
[quoted text clipped - 12 lines]
> > three non-date controls, but not when I clear the value of the one
> > date-formatted control/field that is part of the PK.