Make a combo box dependant on another

Status
Not open for further replies.
Q

QW15IEJyb29rcw

Hi,

I have two combo boxes, one named Division, the other named Sub-Division.

I want to make it so that if you select (for example) Ambulance from the

Division list, the Sub-Division list will only show related items, like NHS,

Private, Air. The lists are as follows:

Ambulance

Air

NHS

Private

Voluntary

Vehicle Builder

Export

Distributor

End User

Group

Hospital

NHS

Private

Distributor

Industry

N/A

Mortuary

Distributor

Funeral Director

The code I have so far is:

----------------------------------------------------------------Sub Item_CustomPropertyChange(ByVal Name)

Select Case Name

Case "cboDivision"

Call SetSubDivision

End Select

End Sub

_______

Sub SetSubDivision

Set objInsp = Item.GetInspector

Set objPage = objInsp.ModifiedFormPages("General")

Set Division = objPage.Controls("cboSubDivision")

Select Case Item.UserProperties ("cboDivision")

Case "Ambulance"

cboSubDivision.List = Split("Air,NHS,Private,Vehicle Builder,Voluntary",",")

Case "Export"

cboSubDivision.List = Split("Distributor,End User,Ferno Group",",")

Case "Hospital"

cboSubDivision.List = Split("Distributor,MOD,NHS,Private",",")

Case "Industry"

cboSubDivision.List = Split("N/A",",")

Case "Mortuary"

cboSubDivision.List = Split("Distributor,Funeral Director",",")

End Select

End Sub

----------------------------------------------------------------I'm not sure if this is correct, or where to put it.

Help would be appreciated!

Thanks,

Amy
 
S

Sue Mosher [MVP]

Code behind an Outlook form is placed in the code window displayed by the

View Code command in design mode.

cboDivision sounds like the name of a control, not a custom property. See

http://www.outlookcode.com/article.aspx?ID=38 for an example of the correct

usage of CustomProperty Change and how to refer to properties of a control.

Sue Mosher
 
Q

QW15IEJyb29rcw

Hi Sue,

It was actually your solution I found online, and I tried to modify it to

suit my needs.

I've had a look at the site you posted, but I'm finding it a bit difficult

to understand.

If I go to the Value tab of Properties (as shown on the website), I have

actually used the name: Division. I used cboDivision when you go into Display

tab.

"Sue Mosher [MVP]" wrote:


> Code behind an Outlook form is placed in the code window displayed by the
> View Code command in design mode.

> cboDivision sounds like the name of a control, not a custom property. See
> http://www.outlookcode.com/article.aspx?ID=38 for an example of the correct
> usage of CustomProperty Change and how to refer to properties of a control.
> > Sue Mosher
> > >

>>
 
S

Sue Mosher [MVP]

That suggests that Division is the name of the *property* and cboDivision is

the name of the *control*. Only the property value is relevant in this

scenario. "Division" would be the string value needed in your Case statement

in the Item_CustomPropertyChange handler and Item.UserProperties

("Division") would be the value in the later Select Case statement.

You should also change this statement:

Set Division = objPage.Controls("cboSubDivision")

to

Set cboSubDivision = objPage.Controls("cboSubDivision")

so that there is a cboSubDivision object variable for all the subsequen

cboSubDivision.List expressions.

Sue Mosher
 
Q

QW15IEJyb29rcw

> You should also change this statement:

> Set Division = objPage.Controls("cboSubDivision")


*Slaps forehead* I can't believe I did that! Well spotted mistake :D

I think I understand what you mean now, so property name is like the field

name, which you see in the field chooser, and control name is basically the

name of the text box / combo box etc?

I've changed my script, and now works perfectly :D Thanks!
 
S

Sue Mosher [MVP]

Yes, "property" and "field" are synonyms, and the property and the control

that displays it are two completely different entities.

Glad to hear you have it working.

Sue Mosher

"Amy Brooks" <AmyBrooks> wrote in message

news:5C985DF9-5FF1-4E30-A94A-C97E0CA9B42F@microsoft.com...
> > You should also change this statement:
>

>> Set Division = objPage.Controls("cboSubDivision")


> *Slaps forehead* I can't believe I did that! Well spotted mistake :D

> I think I understand what you mean now, so property name is like the field
> name, which you see in the field chooser, and control name is basically
> the
> name of the text box / combo box etc?

> I've changed my script, and now works perfectly :D Thanks!
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
Q Follow up: Make a combo box dependant on another Outlook VBA and Custom Forms 6
R List folders in a combo box + select folder + move emails from inbox to that folder + reply to that email Outlook VBA and Custom Forms 1
G Using Data From Combo Box in Appointment Body Outlook VBA and Custom Forms 6
P Custom Outlook form_Validations in combo box Outlook VBA and Custom Forms 0
S Outlook form - Combo box for deciding who to send form to Using Outlook 1
M details with the combo box Exchange Server Administration 3
L Combo Box Using Outlook 157
Q Load a recipient based on a value in a combo box Outlook VBA and Custom Forms 7
F Outlook 2010 - outlook userform and combo boxes Using Outlook 9
M Need help with combo boxes in messages! Using Outlook 10
M Outlook 2007 / Vista / Windows XP best combo needed BCM (Business Contact Manager) 2
Terry Sullivan E-Mails Sent Using a Group Box Result in 70 Kickbacks Using Outlook 5
N Private check box in table view Using Outlook 0
Commodore Folders always closed in move/copy items dialog box Using Outlook 3
P IMAP Folders Dialog Box Using Outlook 1
C Custom Outlook Form - Populate Information from Radio Button / Check Box Using Outlook 0
J Program Checkbox that will activate a text box in a Outlook fallible form. Outlook VBA and Custom Forms 1
CWM030 Call me old if you want. OL 2016 font size out of the box. Using Outlook 3
P Suppress dialog box on email check error? Using Outlook 5
E Don't want Inbox shown when login box is shown Using Outlook 1
stephen li VBA Outlook send mail automatically by specified outlook mail box Outlook VBA and Custom Forms 1
A GetSelectNamesDialog Pre-fill search box Outlook VBA and Custom Forms 12
P Outlook 2010 sending safe senders email to junk box Using Outlook 8
K Sharedmail box Outlook VBA and Custom Forms 4
Diane Poremsky Outlook Suggestion Box at Uservoice New Slipstick.com Articles 0
D Emails do not appear in Sent box! Using Outlook 4
T OL2010 Password box keeps appearing. Using Outlook 6
A From box in custom outlook Form Outlook VBA and Custom Forms 0
Kristine RS box added in Favorites disappears Using Outlook 6
L An () has been inserted after the address in an address box; how do I remove them. Using Outlook 1
rohit I want to Populate Popup box while sending any email with attachment. Outlook VBA and Custom Forms 4
rohit I want to Populate Popup box while sending any email with attachment Using Outlook 1
moron save as & file location dialog box popup Outlook VBA and Custom Forms 2
Ross Garvey Dialogue box opens as I exit Using Outlook 2
P BCM 2013 Contacts Form Drop Down Box Bug BCM (Business Contact Manager) 1
C Outlook 2013 - Email Gets Sent - But Does Not Move From Outbox to Sent Box Using Outlook 4
G Enter Network Password box pops up every few seconds Using Outlook 2
V In Box Issues Using Outlook 1
S 2010 outlook today looks like an empty email box Using Outlook 4
S Custom yes/no message box. Using Outlook 0
L Auto-set followup/reminder popup box for ALL sent emails. Using Outlook 0
P VBA for Dialog Box when sending Email Using Outlook 8
V Clicking box to delete junk mail doesn't stay Using Outlook 2
M Send receive Progress Box Using Outlook 4
M How do I link a drop down box to a percent complete box Using Outlook 4
B In Box Empty Using Outlook 5
M Preventing conversation from moving to the top of the message box? Using Outlook 7
A Dialogue box 'Do you want to save this file?' Save or Cancel From: C:\Users\Ad Using Outlook 5
S OL 2007 user typing. into file box results in .htm.msg Using Outlook 5
K Need to get OOO messages more than once for the same email box Using Outlook 2
Similar threads


















































Top