C
Charles E Finkenbiner
Hi All,
I have SQL lookup that does not do exactly what I want. I am new to
Access and SQL so I am doing some practice databases. I have a table
with 3 fields:
Table - Counties:
ID - Primary Key
Name
StateCode
CountryCode
ID is an AutoNumber and the other 3 are text. I am not using any forms
at the moment, just opening the database. I am trying to get
CountryCode filled automatically once I enter the StateCode. There is
another table called States which contains the CountryCode for each
state. I have tried using a lookup in field CountryCode, the SQL code
looks like this:
SELECT States.CountryCode FROM States WHERE
Counties.StateCode=States.Code ORDER BY States.Code;
I have 2 problems with my attempts. 1 - none of the CountryCode fields
gets filled in automatically, once I enter the StateCode like I thought
it would. 2 - the first time I manually enter a CountryCode or click on
the down arrow of the combobox I get a parameter dialog box. The dialog
asks me for Counties.StateCode but that value is already in the correct
field.
Once I enter the Counties.StateCode once I can manually enter
CountryCodes until I close the database. I can not enter an incorrect
CountryCode for a State, which is what I want. I tried changing the
WHERE statement order but that did not fix anything either.
How can I get it to automatically insert the CountryCode and how do I
stop the parameter dialog from popping up?
Thanks for any and all help,
Charles
I have SQL lookup that does not do exactly what I want. I am new to
Access and SQL so I am doing some practice databases. I have a table
with 3 fields:
Table - Counties:
ID - Primary Key
Name
StateCode
CountryCode
ID is an AutoNumber and the other 3 are text. I am not using any forms
at the moment, just opening the database. I am trying to get
CountryCode filled automatically once I enter the StateCode. There is
another table called States which contains the CountryCode for each
state. I have tried using a lookup in field CountryCode, the SQL code
looks like this:
SELECT States.CountryCode FROM States WHERE
Counties.StateCode=States.Code ORDER BY States.Code;
I have 2 problems with my attempts. 1 - none of the CountryCode fields
gets filled in automatically, once I enter the StateCode like I thought
it would. 2 - the first time I manually enter a CountryCode or click on
the down arrow of the combobox I get a parameter dialog box. The dialog
asks me for Counties.StateCode but that value is already in the correct
field.
Once I enter the Counties.StateCode once I can manually enter
CountryCodes until I close the database. I can not enter an incorrect
CountryCode for a State, which is what I want. I tried changing the
WHERE statement order but that did not fix anything either.
How can I get it to automatically insert the CountryCode and how do I
stop the parameter dialog from popping up?
Thanks for any and all help,
Charles