VBA Drop Down Box Activation (1 Viewer)

peterengland

New member
Local time
Today, 10:38
Joined
Apr 15, 2005
Messages
7
I have a customer form. On it I have got a drop down box with the following choices in it: Private, Business, Caravan.

I have VB code that blanks out none private fields on the customer form, VB code that blanks out none business fields on the customer form and VB code that blanks out none Caravan fields on the customer form. To activate the code I click on a macro button.

Is it possible to have the different codes activated when the choice is click on in the drop down box for example when you click on business the VB code that blanks out none business fields on the form activates.

Any Help would be much appreciated
Regards Peter :) :)
 

FoFa

Registered User.
Local time
Today, 12:38
Joined
Jan 29, 2003
Messages
3,672
Basically on the click event you have to test for which code was selected, then run the proper code. If you have macro/s to do the proper actions, you could just DOCMD.RUNMACRO "macroname" in the click event. Just depends if you have one macro or 3 (using your example). If you have 3 macros then you would have to check for the selected value and run the proper macro. If you have one macro that does the checking already, you can just run it instead. Or you can convert the whole thing to VBA in the click event.
As an example
 

peterengland

New member
Local time
Today, 10:38
Joined
Apr 15, 2005
Messages
7
A Little Help Please

FO FA thanks for your help but I am still a little stuck. I think I understand that the code you gave me (DOCMD.RUNMACRO "macroname") will run a macro when you click on an entry but how do I check for the selected value and run the proper macro. Sorry if this is a simple question or you have answered this already but I am new to this. Thank you very much for your help
Regards
Peter :) :)
 

FoFa

Registered User.
Local time
Today, 12:38
Joined
Jan 29, 2003
Messages
3,672
Assumption - ComboBox is called Combo1

One Way:
Select Case Combo1
Case "Private" DOCMD.RUNMACRO "mPrivate"
Case "Business" DOCMD.RUNMACRO "mBusiness"
Case "Caravan" DOCMD.RUNMACRO "mCaravan"
End Select

Another Way:
If Combo1 = "Caravan" then DOCMD.RUNMACRO "mCaravan"
If Combo1 = "Business" then DOCMD.RUNMACRO "mBusiness"
If Combo1 = "Private" then DOCMD.RUNMACRO "mPrivate"
 

peterengland

New member
Local time
Today, 10:38
Joined
Apr 15, 2005
Messages
7
Me Again Sorry

Had ago and reached another problem. The VB code below is what is behind the three command buttons which when I click either of them they hide the fields:

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.Dom1.Enabled = False
Me.Dom2.Enabled = False
End Sub

I understand that the code you very kindly gave me will load a Macro when you click on the relevant text but how do I get a Command to do this. Alternatively how do I turn a command into a macro.

I you guess you have already gathered I am clueless on this subject and sorry if I have confused the situation by originally asking the wrong question. Thank you for your help so far
Peter
 

peterengland

New member
Local time
Today, 10:38
Joined
Apr 15, 2005
Messages
7
All Sorted

Ignore the last post all sorted thank you very much for you help FO FA. Kind Regards
Peter :) :) :)
 

Users who are viewing this thread

Top Bottom