PDA

View Full Version : MS Word - Combo box on form to populate text boxes



chimp
12-01-2005, 06:37 AM
i have a word document that i am trying to semi automate a few of the functions i have put on the page...

Example...

In the attached document you will see i have three drop down boxes, which i believe could technically be reduced to just 1...

this is where my problem starts.

i want to be able to change JUST the salary drop down box and both the grade and the shift premium would then adjust automatically.

Can this be done..

the thing i am struggling with is where would i store the data to say that if the salary is ?14,527 the Grade would be "A" and the shift premium would be "15%"

please any help on this matter would be much appreciated.

at the bottom of the attached document are a list of some of the grading structures: you will see that the unique item is the Salary! field

lucas
12-01-2005, 09:34 AM
This would be much easier to do in Excel using LOOKUP or VLOOKUP. I'm no word expert so I don't know whether it can be done easily or at all in Word.

chimp
12-01-2005, 09:36 AM
yeah, i have done similar things before in Excel, but this is for a standard document we use in work, instead of typing the figures in each time, they want to just chnge one box and the rest all adjust accordingly...

but...

the documents are all in word

lucas
12-01-2005, 09:48 AM
If you must work in Word you could try inserting an Excel Worksheet object and go from there. Insert-Object-MS Excel Worksheet

mdmackillop
12-01-2005, 11:03 AM
Hi,
I think you need to run a macro when the dropdown is selected. Something along the lines of the following. I've not done much word automation and am having trouble triggering the macro.:( Maybe someone else can assist here.

Sub FillForm()
Dim MyDrop
With ActiveDocument
Set MyDrop = .FormFields("DropDown1").DropDown
Select Case MyDrop.ListEntries(MyDrop.Value).Name
Case Is = "A"
.FormFields("Text1").Result = "12,850"
.FormFields("Text2").Result = "15%"
Case Is = "B"
.FormFields("text1").Result = "14,527"
.FormFields("text2").Result = "15%"
'.... and so on
End Select
End With
End Sub

mdmackillop
12-01-2005, 11:12 AM
Macro problem solved. Your macro security was set to High so nothing happened!
The values change when you tab to the next field.