Question Dim Statement - Run Time Error

reidhaus

Registered User.
Local time
Today, 14:36
Joined
Dec 18, 2007
Messages
23
Somehow a form has suddenly stopped working. I get the following error:
Run-time error '-2147352567 (80020009)':
You tried to assign the Null value to a variable that is not a Variant data type.

Not a clue what I could have done / changed to cause this to happen but the debugger highlights line 2 (InventoryItem = Null) as being incorrect (see below). Any ideas on how to fix this?

Private Sub Category_AfterUpdate()
InventoryItem = Null
InventoryItem.Requery
End Sub
Private Sub Form_Current()
InventoryItem.Requery
End Sub
Private Sub Command17_Click()
On Error GoTo Err_Command17_Click

DoCmd.Close
Exit_Command17_Click:
Exit Sub
Err_Command17_Click:
MsgBox Err.Description
Resume Exit_Command17_Click

End Sub
 
not a Variant data type

The variable is probably restricted to specific input and inadvertantly was passed a Null which it wasn't prepared to handle. Try changing the definition of the variable to:

Dim InventoryItem as Variant

Just for safety sake while trouble shooting, just comment out the old definition by placing a single quote ' in front of that line then adding the line above to take its place, then test the form again.

Cheers
Goh
 
it doesn't look like INVENTORYitem is even a variable. if it's a tbox, just switch it to 0-length string: ""
 
If InventoryItem is a control on a form you should use

Me.InventoryItem

because sometimes it does not see it as a control if you don't qualify it as such, especially if you don't have OPTION EXPLICIT at the top of your General Declarations of the module that is in.
 

Users who are viewing this thread

Back
Top Bottom