G
Guest
I have a table that imports data from a file. However, I want to use an
address depending on a condition in the data. Here is the scenario.
Everyone in the table works at the same location, call it "1234 Main St,
Sydney, MN 66789." However, if the data file has the person's home address
I want the query to update the table with the home address.
Here is what I have done so far. Since everyone works in the same place, I
have hard coded the work address into the table:
SELECT "1234 Main St." AS Address, "Sydney" AS City, "MN" AS State, "66790"
AS ZIP
by doing this every single person in the table has the same default address,
which is the work address.
Now here is the trick, if the data file has a home address then I want to
replace the work address with the home address, if there is no home address
then I want to simply default to the work address (which is already the
default).
So, if the person lives at 999 Oak St., Sydney, MN 66793 I want to replace
the default work address with the home address. The original data file has
a field, "HOME_ADDRESS' which is populated with either Y, YES, N, or NO. So
I will have to use the "LIKE" function, here is what I want to do in pseudocode:
If [HOME_ADDRESS] like 'Y*' then
INSERT INTO TABLE
[(HOME_ADDRESS.Street),(HOME_ADDRESS.city),(HOME_ADDRESS.State),(HOME_ADDRESS.Zip)]
Since the table is already populated with the work address for every
individual there is no need for an "ELSE" statement.
I have been looking and found that the IIf statement may do what I want, but
I haven't been able to get the syntax correct, or I really don't understand
it. What would the proper access SQL statement be or could I do something
in the design view?
address depending on a condition in the data. Here is the scenario.
Everyone in the table works at the same location, call it "1234 Main St,
Sydney, MN 66789." However, if the data file has the person's home address
I want the query to update the table with the home address.
Here is what I have done so far. Since everyone works in the same place, I
have hard coded the work address into the table:
SELECT "1234 Main St." AS Address, "Sydney" AS City, "MN" AS State, "66790"
AS ZIP
by doing this every single person in the table has the same default address,
which is the work address.
Now here is the trick, if the data file has a home address then I want to
replace the work address with the home address, if there is no home address
then I want to simply default to the work address (which is already the
default).
So, if the person lives at 999 Oak St., Sydney, MN 66793 I want to replace
the default work address with the home address. The original data file has
a field, "HOME_ADDRESS' which is populated with either Y, YES, N, or NO. So
I will have to use the "LIKE" function, here is what I want to do in pseudocode:
If [HOME_ADDRESS] like 'Y*' then
INSERT INTO TABLE
[(HOME_ADDRESS.Street),(HOME_ADDRESS.city),(HOME_ADDRESS.State),(HOME_ADDRESS.Zip)]
Since the table is already populated with the work address for every
individual there is no need for an "ELSE" statement.
I have been looking and found that the IIf statement may do what I want, but
I haven't been able to get the syntax correct, or I really don't understand
it. What would the proper access SQL statement be or could I do something
in the design view?