Help with syntax for passing a field value to a lookup query?

K

keithb

I am trying define a lookup field in a table where the values displayed
depend on the content of an adjacent field.
For example:

Lookup Table:
State-------City
AZ--------Phoenix
AZ--------Tempe
CA--------Los angeles
CA--------San Francisco

If the state field in the primary table contains AZ, I want the lookup combo
box to display only Phoenix and Tempe...

What is the correct syntax for passing a value from a field in the primary
table to a lookup query? When I use "
.[field]" I get a prompt for a
value when the table is opened. When I use "table![field]", the lookup combo
box contains no entries.

I used to know how to do this, but I forgot..

Thanks,

Keith
 
K

keithb

I changed my table lookup definition to use the form: Table![table
name]![field name]. When I open the primary table I still get a dialog box
asking for the content of [tablename]![field]. I don't know if it matters,
but Access ads square braces around "Table" in the query. Any other ideas?

Thanks,

Bob Miller said:
Table![table name]![field name]
the word Table needs to be the first in the above, not the name of a
table.
keithb said:
I am trying define a lookup field in a table where the values displayed
depend on the content of an adjacent field.
For example:

Lookup Table:
State-------City
AZ--------Phoenix
AZ--------Tempe
CA--------Los angeles
CA--------San Francisco

If the state field in the primary table contains AZ, I want the lookup
combo
box to display only Phoenix and Tempe...

What is the correct syntax for passing a value from a field in the
primary
table to a lookup query? When I use "
.[field]" I get a prompt
for a
value when the table is opened. When I use "table![field]", the lookup
combo
box contains no entries.

I used to know how to do this, but I forgot..

Thanks,

Keith
 
K

keithb

Thank you. Now I understand what is happening.

Keith

Duane Hookom said:
I trust you are not attempting to create lookup fields in a table design.
For information on "why", check
http://www.mvps.org/access/lookupfields.htm.

You can and should use lookups (combo boxes) on forms. If you want to find
out how to cascade your combo boxes on a form, check this link on Roger
Carlson's web site
http://www.rogersaccesslibrary.com/TableOfContents3.asp#C.

--
Duane Hookom
MS Access MVP
--

keithb said:
I am trying define a lookup field in a table where the values displayed
depend on the content of an adjacent field.
For example:

Lookup Table:
State-------City
AZ--------Phoenix
AZ--------Tempe
CA--------Los angeles
CA--------San Francisco

If the state field in the primary table contains AZ, I want the lookup
combo box to display only Phoenix and Tempe...

What is the correct syntax for passing a value from a field in the
primary table to a lookup query? When I use "
.[field]" I get a
prompt for a value when the table is opened. When I use "table![field]",
the lookup combo box contains no entries.

I used to know how to do this, but I forgot..

Thanks,

Keith
 

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