Disable Delete in Combo Box

Catalina

Registered User.
Local time
Yesterday, 16:47
Joined
Feb 9, 2005
Messages
471
On the form for the Addresses I have a Combo Box for picking a Country.

When I hit the Delete button while the cursor is in the box I get a Message saying:

'You cannot assign the Null value to a Variable that is not a Variant data type'

The box has 2 columns, CountryName (Text) and CountryID (number), the second is the bound column.

I tried to Set the Warnings off, catch the error in the After Update Event, but
nothing helps to get rid of the Error Message.

Is there a way to Disable the Delete button, while in he box?
Or is there a better solution?

Thanks.
 
Why would you want to use the delete button while in the combo box? Are you thinking a user might press it?
 
i did not understand exactly the problem you're having, but if you would like to disable a Delete button, while you are in your combo box, you may put the following on the OnGotFocus event of your combo

Code:
Me.DeleteButtonName.Enable = False

Similarly you can enable your delete button, when your combo loses the focus (OnLostFocus).
 
In the KeyPress event you can put:

Code:
If KeyAscii = 8 Then
    KeyAscii = 0
End If
 
Delete in Combo Box

I think my question was not correct, sorry about that.

I get the Error Message when I press the Delete Key while the Cursor is
in the Combo Box.
So, I don't want to disable a Delete Button on the Form, just need to
prevent users to delete the contents of the Combo Box or
find another way to get rid of the message.

I tried the On Key Press Event as suggested, doesn't work.

Thanka again.
 

Users who are viewing this thread

Back
Top Bottom