Type Mismatch from ComboBox to Module

PRD

Registered User.
Local time
Yesterday, 19:30
Joined
May 18, 2011
Messages
72
I have a ComboBox on a form which shows a list of valid names. After a name is selected I run a Macro (using the ‘AfterUpdate’ option) which in turn passes the name to a Module for further processing. If a name is selected from the list everything works fine but I have some users who use the Delete Key to space out the name and when this happens I get a ‘Type Mismatch‘ error. The field name in the Module is defined as a ‘String’ and so my question is what can I do to stop the ‘Type Mismatch‘ error from being displayed? Thank you for your time.
 
Hi
The field name in the Module is defined as a ‘String’
You could try defining this as a variant instead.

Also, In the After Update event of the combo box you could check its value with something like:
Code:
If Not IsNull(Me.ActiveControl) Then
    'Call your Function/Sub here
End If
 
Bob -

Defining the field as Variant seems to have done the trick, thanks for your help!
 
Hi PRD

Glad you've got it working.
FYI. A string can not hold a "Null" value, but a variant can.
 

Users who are viewing this thread

Back
Top Bottom