Look Up Data Type + IF Validation Rule

ExcelMercy

Board Regular
Joined
Aug 11, 2014
Messages
151
Hello,


I would like a Data Type "Look Up". Based on what is selected, I want the next field which is also a Look Up to offer certain options based on what is picked in the first Look Up field.



Example:


Field Name
Data Type
User_IDAutoNumber
User_StateLook Up
User_CityLook Up

<tbody>
</tbody>

__________________

User_State
New York
Tennessee
Oregon

<tbody>
</tbody>

__________________

User_City Look Up:
Column1
Column2
Column3
NashvilleSalemNew York City
MemphisPortlandBuffalo
KnoxvilleEugeneRochester

<tbody>
</tbody>





Anyways, I need something that will make it so based on what option is picked in the User_State. This will determine which column is allowed to be pick from.




I know this isn't correct, but in terms of code this is kind of what I'm after.

= if(User_State = "New York", User_City = Column3, if(User_State = "Tennessee", User_City = Column1, if(User_State = "Oregon", User_City = Column2, "")))


I was thinking Validation area would be the area I should edit?


- I can do either custom entry or look up to a table, it doesn't matter to me.




Any help would be greatly appreciated!
Thank you
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
I would have a table that had both State and City in it. The State would be duplicated, of course, but for Salem, Portland, and Eugene, the State would be Oregon for each one. Then you can look up City based on State. Make sense?
 
Upvote 0
Ok, so like:


Table: State
St_State
Tennessee
Oregon
New York

<tbody>
</tbody>



Table: State_City
StC_State
StC_City
TennesseeNashville
TennesseeMemphis
TennesseeKnoxville
OregonSalem
OregonPortland
OregonEugene
New YorkNew York City
New YorkBuffalo
New YorkRochester

<tbody>
</tbody>


Table: User Design View

Field Name
Data Type
User_IDAutoNumber
User_StateLook Up (from table: State)
User_CityLook Up (from table: State_City)

<tbody>
</tbody>



How would I make it so User_City's options are based on what's in User_State's field?





Did you mean filling User_State & User_City solely from Table: State_City? How would I go about removing the duplicates? Plus how would I make User_City dependent on User_State's answer?
 
Last edited:
Upvote 0
You could use GROUP BY or DISTINCT to remove duplicates:

Code:
SELECT DISTINCT StC_State FROM State_City;

Where exactly are you wanting to do this "Look up?" So to get only the right values for the selected City, you'd do something like this:

Code:
SELECT StC_City FROM StC_State WHERE StC_State = [your value from a...form(?) that you pass in];

The value could be something like Forms!frmChooseLocation!cboState.Value (I can't remember the exact syntax right now, but should be close)

There are also other ways of passing in the State value. I hope this helps.
 
Upvote 0
Should I be trying to group them using a Query?

I was attempting to to this table-to-table. I want the "Look Up" directly in one of my tables, from another table.


I tried what you suggested, but I'm to much of a novice to get it working. :(
 
Upvote 0
I'm sorry - I don't have MS Access available to me most days. If you create the separate tables and link them, that would be a good start.
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top