Error when adding a new record?

M

M S

When I use my form to add a new record, I get the following error:

"You tried to assign the Null value to a variable that isn't a Variant data
type. (Error 3162)"

The form opens fine, but as soon as I try to enter data in any control, this
comes up. Issue is that the form and tables work fine, but this message is
annoying.

Any ideas?
 
W

Wayne Morgan

You have some code that is being run that is trying to assign a Null value
to a variable and that variable isn't of the Variant data type and so won't
accept a Null value. If the record is a new record, the code could be in the
form's BeforeInsert event otherwise, for the error to appear no matter which
control you are typing in then try the form's Key Down, Key Press, or Key Up
events. If it only happens when you type in a certain control, try the
Key... events for that control and the Before Update and After Update events
of that control.
 
M

M S

Thank you for the help. I looked around but couldn't find anything at all
that would cause this. The form is a subform which is one of the tabs in a
four tab main form. It is bound to a complete different table.

The only code I have in this subform is:

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
On Error Resume Next

'Map out the page up and page down keys so new underlying records
'can't be added to this table.

Select Case KeyCode
Case 33, 34
KeyCode = 0
End Select
End Sub

No idea what else is causing it... any other suggestions on where to look?

-M
 
M

M S

Forget it....

It was the link between the child and main ID/keys on the subform to the
mainform.

-M
 

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