Type mismatch on combobox (1 Viewer)

AndyCompanyZ

Registered User.
Local time
Today, 00:58
Joined
Mar 24, 2011
Messages
223
Still more VBA solving for me to do. I can't work out why I am getting a type mismatch on this piece of code:

Code:
Private Sub EventStatus_Change()
If (Me.EventStatus.Value = 3) And (Me.ScheduledNumber > 0) Then
MsgBox "There are already delegates scheduled on this event. Please inform the delegates and reschedule", VbMsgBoxStyle = vbOKOnly
End If
End Sub

The combobox has 3 options which are
On Hold [1], Confirmed [2] , Cancelled [3]
The bound column is 1 which is the number but I'm wondering if that is where the problem is or is it that the control source is EventStatus which is a table field. I have tried changing the combobox name but same thing happens I'm wondering if the control source should be the combobox or not.
 

spikepl

Eledittingent Beliped
Local time
Today, 01:58
Joined
Nov 3, 2010
Messages
6,142
1. Wrong event. Use AfterUpdate. OnChange fires for each typed character
2. Name the combo cboEventStatus -sometimes there ARE problems, if the control source has the same name
3. Use Me.cboEventStatus - that is the default version of Me.cboEventStatus.Value

Update:

And as per our previous discussion: dont'assume - always check WHAT is being fed into the expression that gives you trouble
 
Last edited:

AndyCompanyZ

Registered User.
Local time
Today, 00:58
Joined
Mar 24, 2011
Messages
223
Thanks again Spike. I tried those but it still came up with mismatch but then I removed the MsgBoxStyle from the end and it worked, any idea what was wrong with that.
 

spikepl

Eledittingent Beliped
Local time
Today, 01:58
Joined
Nov 3, 2010
Messages
6,142
Yeah.

MsgBox "There are already delegates scheduled on this event. Please inform the delegates and reschedule", vbOKOnly
should do it.

Pay attention to what pops up while you type eg MsgBox - the Intellisense should guide you
 

boblarson

Smeghead
Local time
Yesterday, 16:58
Joined
Jan 12, 2001
Messages
32,059
As spike says, look at the Intellisense to see what needs to be put there. It is normally just like this:

MsgBox "Some Message", vbOkOnly, "Caption Here"

Or

If MsgBox("Do you want to...", vbYesNo + vbQuestion, "Caption Here") = vbYes Then
...etc.
 

AndyCompanyZ

Registered User.
Local time
Today, 00:58
Joined
Mar 24, 2011
Messages
223
Thanks I need now to get it to open a form on the ok button of the msgbox but that's for another day lol
 

boblarson

Smeghead
Local time
Yesterday, 16:58
Joined
Jan 12, 2001
Messages
32,059
And additionally, if you want to specify the argument like vbMessageBoxStyle then you can use what you did PROVIDED you do it like this:

vbMessageBoxStyle:= vbOkOnly

it needs the colon and equals sign: :=
 

Users who are viewing this thread

Top Bottom