Type Mismatch

Dhamdard

Dad Mohammad Hamdard
Local time
Today, 22:30
Joined
Nov 19, 2010
Messages
103
In a form, I have two fields 1) BroadcastType and 2) Station. BroadcastType has a combo box with multiple value select property enabled. In 'after update' event property of 'broadcasttype' field, I have written this procedure:
Code:
if me.broadcasttype="Nationwide" Then
me.station.enabled = True
Else
me.station.enable = False
End If

But when I select a value from the combo box from 'broadcasttype' field, I get this message "Type Mismatch". I tried it with other fields and it works properly. It doesn't work with 'braodcasttype' field. Is it because that this field has multiple value select property enabled? How can I write a VBA code to make it happen?

Thanks,
Dad
:)
 
What code line does it highlight when you click Debug?
 
This one:
Code:
if me.broadcasttype="Nationwide" Then
 
It's only a comparison, I don't see why it should error. Can you upload a test database?
 
Sounds like you are trying to compare text but the actual bound column of the combo is set to an ID field which is a number.

You may need to change it to:

if me.broadcasttype.Column(1) = "Nationwide" Then
 
Thanks, Sir. It worked. Now another request:

If value of 'BroadCastType' is equal to 'Worldwide' then I would like the 'station' field to automatically select all items from the combo box. The station field itself is a combo box. Would you help me with the procedure?

Thanks so much,
Dad
 
Is this a multi-select combo box you are talking about? If so, you will need an update or append query to select each of the items. I don't work with those so much yet so I can't give you much help with that. I suggest posting another thread for this specific request and make it clear that it is an Access 2007 or Access 2010 muti-valued field you are working with.

If it isn't, then combo's don't have multiple selections.
 

Users who are viewing this thread

Back
Top Bottom