VBA MessageBox - Yes No

carl6885

Registered User.
Local time
Today, 04:58
Joined
Nov 16, 2011
Messages
82
Hi

I have a piece of code that when executed off the back of a combo box changing it displays a Yes/No message box, however it isn't doing what I want it to do.

User selects combo box value, after update: message box appears asking if they want to add another area/team? User has yes or no, if user selects yes then it should enable a combo box below etc.

Code as follows:

Private Sub cboTeamCaused1_AfterUpdate()

'Me.cboAreaCaused2.Enabled = True

messagemore = MsgBox("Do you want to add another area/team?", vbYesNo, "Another?")

If (messagemore = vbayes) Then

Me.cboAreaCaused2.Enabled = True

ElseIf (messagemore = vbano) Then

Exit Sub

End If

End Sub

When executed nothing happens - if I put the me.cboAreaCaused2.Enable = True outside of the messagebox it works as expected.

I have tried adding a custom subroutine and then referencing that however that doesn't work.

Can anyone suggest an alternative? Other than not having the msgbox, as I want this to add to the user engagement etc.

Thanks

Carl
 
Write

Option Explicit

as first line of your code module - you should always do that.

This will show the errors of your ways, and also save you lots of grief in the future.
 
Last edited:
Good eyes spikepl!
 
I am such a newbie! Cheers guys!!

For anyone looking and not knowing the answer:

messagemore needed declaring as a string

and

its vbYes/vbNo NOT vbaYes/vbaNo

Thanks guys!!
 

Users who are viewing this thread

Back
Top Bottom