bound combo box, cleared content run time error 3162 (1 Viewer)

mgui

Registered User.
Local time
Today, 01:55
Joined
Nov 18, 2017
Messages
10
I have a bound combo box on my access form. I keep getting a Null Value debug error, when I clear the contents of the box. Say for example I start to type a name in the box and for whatever reason I want clear the name and not continue with inputting information on the form, I get Run-time error '3162': You tried to assign Null value to a value that is not a variant data type.

If I type something in the combo box by mistake, I want to be able to hit the backspace and clear the contents of the box without getting a Run-time error. Is there a code for that and if so what is it and where do I put it?
 

Wayne

Crazy Canuck
Local time
Today, 04:55
Joined
Nov 4, 2012
Messages
176
Is the combo box bound to a field on a table? And is it a combo box on the table or a text field?
 

JHB

Have been here a while
Local time
Today, 10:55
Joined
Jun 17, 2012
Messages
7,732
Do you've any code in one of the combo box's events?
 

mgui

Registered User.
Local time
Today, 01:55
Joined
Nov 18, 2017
Messages
10
The combo box is on a form and there is an after update event procedure code. I am attaching to screenshots.
form screenshot.PNG

cbo box code.PNG
 

Mark_

Longboard on the internet
Local time
Today, 01:55
Joined
Sep 12, 2017
Messages
2,111
If there is no value in your combobox buffer, you need to handle the NULL values. Each time you set another value equal to one in your combobox, you need to handle NULL values. I would wrap each reference to Me.CboName.Column(?) with an NZ that returns a useful response. This also protects you in case the underlying data wasn't filled in (i.e. is actually NULL) .
 

JHB

Have been here a while
Local time
Today, 10:55
Joined
Jun 17, 2012
Messages
7,732
The AfterUpdate event isn't trigged before you leave the combobox control.
And as the way I read your post, that isn't the case.
Could you post your database with some sample data, (zip it because you haven't post 10 post yet)?
 

Users who are viewing this thread

Top Bottom