Macro to auto pop checkbox 17 and 20 if 5, 6, 7 are checked

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to create a macro that will auto populate checkbox 17 and 20 if
5, 6, or 7 have been checked. Outlook 2000
 
Assuming this is a custom form, use the Item_CustomPropertyChange event to
trap changes to custom fields bound to your controls:

Sub Item_CustomPropertyChange(ByVal myPropName)
Select Case myPropName
Case "CheckBox5Field", "CheckBox6Field", "CheckBox7Field"
Item.UserProperties("CheckBox17Field").Value = True
Item.UserProperties("CheckBox20Field").Value = True
Case Else
End Select
End Sub
 
Yes, sorry, it is a custom form. Am I supposed to replace 'myPropName' with
something? It doesn't work. I just copied the macro you listed.
 
My mistake, sorry. The event handler should look like this:

Sub Item_CustomPropertyChange(ByVal Name)
Select Case myPropName
..etc.

You can also use the Event Handler option from the Script menu in the script
editor to construct these handlers.

Don't forget to replace the property name evaluations with those of your own
custom fields (not control names).

--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/
 
I am trying to understand what I have to change because it is not working.
This is what I have:

Sub checkbox()
Sub Item_CustomPropertyChange(ByVal Name)
Select Case myPropName

Case "CheckBox5Field", "CheckBox6Field", "CheckBox7Field"
Item.UserProperties("CheckBox17Field").Value = True
Item.UserProperties("CheckBox20Field").Value = True
Case Else
End Select
End Sub

So is this saying that if CheckBox 5, 6, or 7 have been selected to
automatically check 17 and 20? I apologize for my ignorance.
 
Ugh, I am trying to make one checkbox check another and did successfully do
it with one on one. But, I want any of three checkboxes to automatically
check a fourth and when I do the setting for each of the three (true/false)
only the three checkboxes check and not the fourth.

I did successfully use the bound feature to populate one text box with the
contents of two others although I did have to create two textboxes sidebyside.
 
Functions in the control itself may not be feasible if the logic is too
complicated. A better approach would be to use code, especially since you
can debug it if there are problems with the logic.

Try it the code way, and if you have problems show us your code.
 
I'm sorry Eric. I have tried all sorts of different combinations and I don't
understand why the macro you sent does not work. I tried to 'Name' the
checkbox fields instead of leaving them just CheckBox5 etc (though I don't
know if it really makes a difference).

I could just use the 'bound' feature but when I do all three of the boxes
check besides the one it is supposed to check.

Would an If, Then statement work? I appreciate your patience with me.
 
Yes, I really recommend you use VBScript behind the form to code your logic.
Use Select Case or If Then statements, whatever you prefer.

Just remember that calls to the UserProperties collection to retrieve a
custom field require the name of the *field*, not the name of the *control*
that is bound to that field on the form.

If you have trouble with the code, post a sample of what you have for review.
 
Ok, here is what I'm using. I am taking the 'Name' from the Advanced
Properties list and it is the same as the 'Field' in the Value tab in
Properties box.

Sub Item_CustomPropertyChange(ByVal Name)
Select Case myPropName
Case "Invoiceprogram", "Priceprot", "Tradeshows"
Item.UserProperties("Fulfilled").Value = True
Item.UserProperties("Promo").Value = True
Case Else
End Select
End Sub
 
One small change is needed - you need to use Name in Select Case myPropName:

Sub Item_CustomPropertyChange(ByVal Name)
Select Case Name
Case "Invoiceprogram", "Priceprot", "Tradeshows"
Item.UserProperties("Fulfilled").Value = True
Item.UserProperties("Promo").Value = True
Case Else
End Select
End Sub

--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/
 
Ok, I put that in. What I am seeing is that each time I publish the form, the
macro disappears.
 
Are you entering that code in the "master" form that you enter into design
mode for, or are you maybe customizing an instance of the "master" form
without publishing your changes? Are you doing an actual "publish", or a
"save"?

If you follow these steps, you should always be able to edit an existing
form and publish your changes:

- choose Tools -> Forms -> Design A Form...
- select your Forms Library and choose the existing form that you want to
design
- make your changes, and choose Tools -> Forms -> Publish Form As... and
ensure you choose the same location that you opened the form

If you close the form and repeat the above process, your changes will be
there.

--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/
 
Back
Top