VBA Drop Down Box Activation

peterengland

New Member
Joined
Apr 6, 2005
Messages
7
I wanted a way of blanking out different fields on my customer form depending on weather it is a Business, Private or Caravan customer. The solution I got was to create 3 command buttons and using On Click and then entering the following in the code builder:


Private Sub Command14_Click()
Me.Business1.Enabled = False
Me.Business2.Enabled = False
End Sub

Private Sub Command15_Click()
Me.Caravan1.Enabled = False
Me.Caravan2.Enabled = False
End Sub

Private Sub Command23_Click()
Me.Private1.Enabled = False
Me.Private2.Enabled = False
End Sub


This allowed me to click the command button and for example the business1 and business2 fields greyed out. Also on the form I have a combo box with the following:

Business
Private
Caravan

Instead of click on the command button to activate the VB Code is it possible to click on for example business in the combo box and it load the business VB code.

Sorry for this being so long hope it makes sense and I would greatly appreciate any help/input
Kind Regards
Peter
:biggrin: :biggrin:
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
You need to use one of the events associated with the combobox.

Perhaps After Update.
Code:
Private Sub Combo0_AfterUpdate()
    Caravan1.Enabled = Combo0 = "Caravan"
    Caravan2.Enabled = Combo0 = "Caravan"
    Business1.Enabled = Combo0 = "Business"
    Business2.Enabled = Combo0 = "Business"
    Private1.Enabled = Combo0 = "Private"
    Private2.Enabled = Combo0 = "Private"

End Sub
By the way why do you have seperate fields for business, private and caravan?
 
Upvote 0
Thank You

Cheers Norie it did exacly what I wanted it to do. By the way I do have some seperate fields for business, private and caravan that is why I wanted to know this. Cheers Again
Peter
 
Upvote 0
Peter

Is the data in the seperate fields for Business etc similar data?

If it is then you could just use fields for what that information is and add another to indicate which type of data is it.
 
Upvote 0

Forum statistics

Threads
1,221,904
Messages
6,162,743
Members
451,785
Latest member
DanielCorn

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