I am trying to update a table named Downinfo. The table has three fields
that I am interested in importing the new information into (all text). The
[quoted text clipped - 4 lines]
text). Once the new table is created, how do I relate the two and how do I
make an update query and can this be done automatically with code?
Do you want to find the record in your table for the imported CDCnum
and overwrite the existing InmateNAME and InmateHOUSING fields? Should
the old values simply be overwritten without any warning, of do you
want to check first? What do you want to happen if there is no record
the table for an imported CDCnum - do you want to add a new record? Do
you want the current date and time filled in to DucateTIME and
DucatDATE (which I'd suggest should be combined into one field, but
that's another issue)? Should DucateREASON be left as it was, or
blanked out if there is an existing reason?
I hesitate to give the following since it may Do The Wrong Thing
depending on these questions - but you can create a Query by joining
your imported table to your existing table, joining on CDCnum
(whatever that field is named in your import, it makes no difference).
Change it to an Update Query and put
[importtablename].[InmateNAME]
under the InmateNAME field (using the actual tablename and fieldname
of course); the brackets are required (otherwise it will store the
text string "importtablename.InmateNAME" in every record). Do the same
for the other field.
Store this query, and run it using the DoCmd.RunQuery method (see the
vba online help) or - probably better, since you can trap errors - the
slightly more complex Querydef Execute method.
John W. Vinson [MVP]