Why wont it do?

thorpyuk

Well-known Member
Joined
Mar 14, 2006
Messages
1,453
Dim bfr As Long
bfr = ComboBox1.Value
ComboBox1.Value = bfr: Exit Sub

how come this gives me a "cant change property" error!?

The code is inside my combobox change event...
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
So you want to change the value inside the change event (and change it to what it already is)? Why???
 
Upvote 0
And you want to change the value to the value it was in the first place?:eek:
 
Upvote 0
Apologies for the protracted reply....

It's a snippet of code.

I basically have an exception whereby if a user selects a certain option from the combobox, they get a msgbox, and it exits the routine.

The problem is that the value in the combobox changes, so i wanted a way of reverting it back to what it was originally, if that makes sense? :>
 
Upvote 0
Why is the value in the combobox then??
 
Upvote 0
Well of course it changes - the user picked it.:)

Do you mean you want to revert to the value they had chosen before they chose the one that displays the messagebox?

That's could be possible but it's probably going to be a bit messy if it is.

Is there a reason the value is included in the list?
 
Upvote 0
You may use the Enter event to save the value of the control in a variable before that value is changed and then use the BeforeUpdate event to test the value, display the message and change the control's value back to what it was.
 
Upvote 0
You may use the Enter event to save the value of the control in a variable before that value is changed and then use the BeforeUpdate event to test the value, display the message and change the control's value back to what it was.

If you exit the control to run the code, then yes. (that is my preferred method too) If you want the code to run without the focus leaving the combobox, as with the Change event, then BeforeUpdate isn't triggered at the right time.
 
Upvote 0
It's also possible to test the new value, display the message and change the value back inside the Change event.
 
Upvote 0
Well of course it changes - the user picked it.:)

Do you mean you want to revert to the value they had chosen before they chose the one that displays the messagebox?

Hi Norie - yes, that's exactly what i'd like to do...

GECS - Thanks for your suggestion, i'll look into it...

Rorya - any chance of a cup of tea please? :>

P.S - apologies for the really long pauses before replying! :s
 
Upvote 0

Forum statistics

Threads
1,214,522
Messages
6,120,020
Members
448,938
Latest member
Aaliya13

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top