Glad it worked.
For your followup question, you can use a query like this:
UPDATE [456] SET Background = "Blue"
WHERE Background="Navy" Or
Background="Baby Blue";
You can use multiple criteria in the WHERE clause.
Also, may I recommend that you NOT name tables with just numbers? Or if
you must, enclose the table names in [ ] characters when you use them
in
queries.
--
Ken Snell
<MS ACCESS MVP>
Hey Ken,
Thanks so much!!
It all worked out, thanks to your help... You rock!
Can I perhaps ask you one more question about an update query?
I try to replace some colors within two fields in a table.
BGColor and BRColor.
I was able to create an update query that does only one at the time..
This
is the code i used:
(here Navy will be replaced by Blue)
UPDATE 456 SET Background = "Blue"
WHERE Background="Navy";
Now I have a big list of colors that need to be changed, so I tried to
use
the code:
UPDATE 456 SET Background = "Blue"
WHERE Background="Navy";
UPDATE 456 SET Background = "Blue"
WHERE Background="Baby Blue";
But I get an error on this on this...
Any ideas what I am doing wrong?
Thanks again so much for all the help!
:
So long as the data in the .csv "field" can be matched to the data in
a
field in the ACCESS table, you can do what you seek even without a
primary
key in the .csv file.
Assuming that the textfile is linked or imported as a table named
TextFile:
UPDATE TableName
SET TableName.ProdAmount = TextFile.FieldWithNewValue
WHERE TableName.ProdNumber = TextFile.FieldWithProdNumberValue
AND TableName.ProdAmount <> TextFile.FieldWithNewValue;
--
Ken Snell
<MS ACCESS MVP>
message
Hi Ken,
First of all, sorry for the late responds, I was not able to do
this
earlier.
Second, thank you so much for your answer.
I have played around with it a little but I am afraid I cannot
figure
it
out..
I was successfull of course in linking / importing a new table from
the
CSV
file.
However, you described that you would use the Primary key to find
the
data
to be updated.
Maybe this is where I get stuck?
I have of course a primary key in the main table, but the CSV file
does
not
have the same primary key.
In the main table i need to update the ProdAmount. I have to
somehow
match
the ProdNumbers (that are unique, but not the prim key) and see if
the
amount
(integer) is changed and that needs to be updated..
As described before I have never used the queries in MS-Access so
I'm
a
total newbie to all of this...
Any further suggestions?
Thanks!
:
General process I'd use for this:
1) Import the ".csv" file's data to an empty table in the ACCESS
database.
2) Use an update query to read the data from the "csv" table and
to
update
the data in the permanent table accordingly, using the identifiers
(primary
key) to find/match data and to test if data need to be updated.
To provide more specific suggestions, would need to know more
about
the
actual data and how to know if a data value needs to be updated.
--
Ken Snell
<MS ACCESS MVP>
message
Ok I have a database with several tables, but I need to update
information
in
only 1 table.
To be more exact, only in 1 field!
Example -->
The table: Products
Fields in the table:
ProdId (Prim Key and Autonumber)
ProdNumber (integer / unique, but cannot be used as prim. key!)
ProdDescr
ProdAmount
Now I have a CSV (or excel, I can do both) file exported from
another
program.
This CSV file I have to manually adjust a little, since the
field
names
are
not the same.
Once that is done, I can import the information where it adds,
but...
here
comes my question: How do I update ?
I need to find a way that it will look for the ProdNumber and
when
it
found
that, only updates the ProdAmount field where needed.
This database is not used on the same location where I need to
update
it.
Anyone here who can help me out on how to do this?
All help is very welcome!