A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

update query



 
 
Thread Tools Display Modes
  #1  
Old February 10th, 2007, 06:21 PM posted to microsoft.public.access.queries
DucateAssignment via AccessMonster.com
external usenet poster
 
Posts: 15
Default update query

Is there anyone that knows how to import a txt file into access and create an
update query to update a table?

Any help would be appreciated.

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200702/1

  #2  
Old February 10th, 2007, 09:07 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default update query

On Sat, 10 Feb 2007 18:21:32 GMT, "DucateAssignment via
AccessMonster.com" u30108@uwe wrote:

Is there anyone that knows how to import a txt file into access and create an
update query to update a table?


Yes. Use File... Get External Data... Import (into an existing or a
new table), or File... Get External Data... Link, as appropriate, and
then create an Update query based on that table linked to your local
table.

If you would like a more specific answer, please post a more specific
question.

John W. Vinson [MVP]
  #3  
Old February 10th, 2007, 11:33 PM posted to microsoft.public.access.queries
DucateAssignment via AccessMonster.com
external usenet poster
 
Posts: 15
Default update query

Hey John

I can import the file and make a new table. I don’t know if I should import
the new data into an existing table or should I import the new data into a
new table. After that, how can I link one table to the other and complete
the update.

Thanks again

John W. Vinson wrote:
Is there anyone that knows how to import a txt file into access and create an
update query to update a table?


Yes. Use File... Get External Data... Import (into an existing or a
new table), or File... Get External Data... Link, as appropriate, and
then create an Update query based on that table linked to your local
table.

If you would like a more specific answer, please post a more specific
question.

John W. Vinson [MVP]


--
Message posted via http://www.accessmonster.com

  #4  
Old February 11th, 2007, 12:38 AM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default update query

On Sat, 10 Feb 2007 23:33:45 GMT, "DucateAssignment via
AccessMonster.com" u30108@uwe wrote:

Hey John

I can import the file and make a new table. I don’t know if I should import
the new data into an existing table or should I import the new data into a
new table. After that, how can I link one table to the other and complete
the update.


Since I cannot see your database, and you haven't posted any
information about these tables, the data they contain, how they are
related, or much of anything else, all I can say is "by joining them
on an appropriate field and putting [tablename].[fieldname] into the
appropriate update row cell".

John W. Vinson [MVP]
  #5  
Old February 11th, 2007, 07:25 PM posted to microsoft.public.access.queries
DucateAssignment via AccessMonster.com
external usenet poster
 
Posts: 15
Default update query

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
fields names are CDCnum, InmateNAME, and InmateHOUSING. I also have DucateTO,
DucatREASON, DucatTIME, DucatDATE in the table, however I only need the
first three fields updated. The imported table has three columns without
fields names but the data is CDCnum, InmateNAME, and InmateHOUSING (again all
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?

Thanks

John W. Vinson wrote:
Hey John

I can import the file and make a new table. I donÂ’t know if I should import
the new data into an existing table or should I import the new data into a
new table. After that, how can I link one table to the other and complete
the update.


Since I cannot see your database, and you haven't posted any
information about these tables, the data they contain, how they are
related, or much of anything else, all I can say is "by joining them
on an appropriate field and putting [tablename].[fieldname] into the
appropriate update row cell".

John W. Vinson [MVP]


--
Message posted via http://www.accessmonster.com

  #6  
Old February 11th, 2007, 09:06 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default update query

On Sun, 11 Feb 2007 19:25:08 GMT, "DucateAssignment via
AccessMonster.com" u30108@uwe wrote:

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
fields names are CDCnum, InmateNAME, and InmateHOUSING. I also have DucateTO,
DucatREASON, DucatTIME, DucatDATE in the table, however I only need the
first three fields updated. The imported table has three columns without
fields names but the data is CDCnum, InmateNAME, and InmateHOUSING (again all
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]
  #7  
Old February 11th, 2007, 11:53 PM posted to microsoft.public.access.queries
DucateAssignment via AccessMonster.com
external usenet poster
 
Posts: 15
Default update query

I would like to take the imported table lets call it (update) with field1,
field2, and field3, which contains the new data I need. Then compare the
data in field1 from update with CDCnum, from downinfo, field2 from update
with InmateNAME from downinfo and field3 from update with InmateHOUSING from
downinfo.

1. All the records that match no changes are needed.
2. If the CDCnum and InmateNAME from downinfo match the records in field1 and
field2 from update, only change (overwrite and update without warning) the
InmateHOUSING in downinfo table with field3 from update table for each record
that it applies to.

3. If there is a record(s) found in the downinfo table that are not found in
update table, that record(s) should be deleted (without warning).
4. If there are any records found in the newly imported update table, that
are not in the downinfo table, the new record(s) will need to be added to the
downinfo table in the appropriate columns field1 in CDCnum, field2
inInmateNAME, and field3 in InmateHOUSING in the downinfo table. I would
like the data in the other columns DucateDATE, DucateTIME and DucateREASON to
be blanked. I have another table named AM PM Ducats that I need to update
and leave the remaining data unchanged. So with downinfo, the other columns
should be blanked after the update and with AM PM Ducats the other columns
should remain unchanged after the update.

Thanks


John W. Vinson wrote:
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]


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...eries/200702/1

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:12 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.