lookup or nested if...

  • Thread starter lotsof questions
  • Start date
L

lotsof questions

In a form template, I am adding a combo box containing the
names of 9 different companies. In the next field, I want
to enter the address of the company chosen from the
dropdown in the combo box.

I'm way out on this one..is vlookup specific to excel? and
would a nested "if" statement work?

What would the code and syntax look like....

My thanks and best regards...
 
S

Stephanie Krieger

Hi,

Vlookup is an Excel function, but if I understand you
correctly -- what you want to do is very easy to do in
Word.

It's just a one-line macro (where text1 and dropdown1 are
the names of your form fields):

ActiveDocument.FormFields("Text1").Result =
ActiveDocument.FormFields("Dropdown1").Result

Just create that macro in a module that's contained in
the document, then you can choose to run that macro upon
exiting the dropdown list field or upon entering the text
field. (Select this in the field properties dialog box
for the applicable field -- which you can access from the
right-click menu or the Forms toolbar). Note that the
text field value will update with the dropdown field's
value only when you exit or enter the field where you set
the macro.

Note that, if you create a VBA userform (dialog box) for
your form fields instead of creating form fields within
the document itself, you can easily make this more
dynamic -- so that the text field you want to take on the
dropdown's value will take on the correct value
automatically anytime the dropdown value is changed. If
that's an option for you, let me know and I'll be happy
to give you the code.

Hope this is useful,

Stephanie Krieger
author of Microsoft Office Docuement Designer
email: MODD_2003 at msn dot com
blog: arouet.net
 
L

Lotsofquestions

Stefanie: my thanks but I guess I don't have to "play"
dense here but something(s)? I don't understand...

I have created a UserForm ComboBox which pops up upon
entry into a field. The combobox list contains the
companies to select in the dropdown....the next field is
the address of the respective companies. Once a company
is selected, I would like its respective address to
populate the next field. I believe I understand whats
happening in your (love it!) simple code, but is
the "Text1". Result = referring to the "address list" and
What method do I use to create the address list that
corresponds to the company dropdown?

I understand that I could place this macro as an exit
macro in the "dropdown1" or "companylist" field or as an
entry macro in the "text1" or "addresslist" field..Correct?

Will I create a new module to place the new code?

Sorry! I know enough to be dangerous! Your assistance is
greatly appreciated and I hope to get good enough to take
you up on your offer of userform code soon...
 
J

JB

lotsof said:
In a form template, I am adding a combo box containing the
names of 9 different companies. In the next field, I want
to enter the address of the company chosen from the
dropdown in the combo box.

I'm way out on this one..is vlookup specific to excel? and
would a nested "if" statement work?

What would the code and syntax look like....

My thanks and best regards...
Probaly use a select case statement for this but I don't know what you
are using to get the company address details.

Select Case strCompName
Case "Company1"
'do stuff here to get address
Case "Company2"
'do stuff here to get address
Case Else
'more stuff
End Select

J
 
S

Stephanie Krieger

Hi,

I'm not sure from the way you explained it how you have
this set up. If you're using a UserForm, then you can use
a Change event on the drop-down list to automatically
populate that other field whenever the selected value
from the drop-down changes. It sounded to me like you
were dealing with form controls directly in a document.

If you want to send me the document (or a related
sample), I'll be happy to look at it and give you some
answers that will definitely work. This is easy to do --
but the answer is different depending on what you've got
set up.

You can email the doc to me at MODD_2003 at msn dot com

Best,
Stephanie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top