PC Review Forums Newsgroups Microsoft Access Microsoft Access VBA Modules Deleting records before import

Reply

Deleting records before import

 
Thread Tools Rate Thread
Old 02-08-2007, 04:30 PM   #1
Prachi via AccessMonster.com
Guest
 
Posts: n/a
Default Deleting records before import


Is it possible to delete all records (tables ) at the click of a button?

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Fo...odules/200708/1

  Reply With Quote
Old 02-08-2007, 04:56 PM   #2
=?Utf-8?B?UGFvbG8=?=
Guest
 
Posts: n/a
Default RE: Deleting records before import

Hi Prachi,

to delete all records in a table, on click event of your button put this few
lines of code
docmd.setwarnings false
docmd.runsql ("delete * from name of the table you wanna empty")
docmd.setwarnings true

HTH Paolo

"Prachi via AccessMonster.com" wrote:

> Is it possible to delete all records (tables ) at the click of a button?
>
> --
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Fo...odules/200708/1
>
>

  Reply With Quote
Old 02-08-2007, 05:23 PM   #3
Prachi via AccessMonster.com
Guest
 
Posts: n/a
Default RE: Deleting records before import

thanks for replying..
So this will just delete the records from the local Access application right?
Also once i delete these records I want to import fresh data from the main
database(basically i want to perform File->Get External Data->Import->Type of
database->Name of connection.Is there a way to do this



Paolo wrote:
>Hi Prachi,
>
>to delete all records in a table, on click event of your button put this few
>lines of code
>docmd.setwarnings false
>docmd.runsql ("delete * from name of the table you wanna empty")
>docmd.setwarnings true
>
>HTH Paolo
>
>> Is it possible to delete all records (tables ) at the click of a button?


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

  Reply With Quote
Old 02-08-2007, 05:26 PM   #4
Prachi via AccessMonster.com
Guest
 
Posts: n/a
Default RE: Deleting records before import

Prachi wrote:
>thanks for replying..
>So this will just delete the records from the local Access application right?And instead of the records in the table can I delete all the tables Also once i delete these tables I want to import fresh tables from the main database(basically i want to perform File->Get External Data->Import->Type of
>database->Name of connection.Is there a way to do this.I have an ODBC connection installed on my computer that connects to the Database
>>Hi Prachi,
>>

>[quoted text clipped - 7 lines]
>>
>>> Is it possible to delete all records (tables ) at the click of a button?


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

  Reply With Quote
Old 02-08-2007, 05:44 PM   #5
=?Utf-8?B?UGFvbG8=?=
Guest
 
Posts: n/a
Default RE: Deleting records before import

Yes, if your table isn't a linked table this'll delete the records from the
local table.
Otherwise (i.e. the table is linked) the records will be deleted from the
source (remote) table.
To import the "fresh" data you can do an append query if you have a table
linked to the table source. To do this in VBA (in this case all the fields of
the linked table are appended to the local table assuming the fields name are
the same)
docmd.setwarnings false
docmd.runsql("insert into your local table select your linked table.* from
your linked table")
docmd.setwarnings true


"Prachi via AccessMonster.com" wrote:

> thanks for replying..
> So this will just delete the records from the local Access application right?
> Also once i delete these records I want to import fresh data from the main
> database(basically i want to perform File->Get External Data->Import->Type of
> database->Name of connection.Is there a way to do this
>
>
>
> Paolo wrote:
> >Hi Prachi,
> >
> >to delete all records in a table, on click event of your button put this few
> >lines of code
> >docmd.setwarnings false
> >docmd.runsql ("delete * from name of the table you wanna empty")
> >docmd.setwarnings true
> >
> >HTH Paolo
> >
> >> Is it possible to delete all records (tables ) at the click of a button?

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

  Reply With Quote
Old 02-08-2007, 07:07 PM   #6
George Nicholson
Guest
 
Posts: n/a
Default Re: Deleting records before import

>>docmd.runsql ("delete * from name of the table you wanna empty")
> So this will just delete the records from the local Access application
> right?


Well, *if* "name of table you wanna empy" is a local table, then yes, it
will just delete local data.

Also, keep in mind that instruction only empties *one* table, not all tables
in the application

If you want to empty more than one table, simply repeat that instruction as
many as necessary.
docmd.runsql ("delete * from table1")
docmd.runsql ("delete * from table2")

If you have enforced relationships between tables, you may have to do the
deletes for that group of tables in a specific order (bottom of heirarchy to
top)
Reverse the order when filling those tables again (top of heirarchy to
bottom).

HTH,


"Prachi via AccessMonster.com" <u36281@uwe> wrote in message
news:7619358a536fb@uwe...
> thanks for replying..
> So this will just delete the records from the local Access application
> right?
> Also once i delete these records I want to import fresh data from the main
> database(basically i want to perform File->Get External Data->Import->Type
> of
> database->Name of connection.Is there a way to do this
>
>
>
> Paolo wrote:
>>Hi Prachi,
>>
>>to delete all records in a table, on click event of your button put this
>>few
>>lines of code
>>docmd.setwarnings false
>>docmd.runsql ("delete * from name of the table you wanna empty")
>>docmd.setwarnings true
>>
>>HTH Paolo
>>
>>> Is it possible to delete all records (tables ) at the click of a button?

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



  Reply With Quote
Old 02-08-2007, 07:44 PM   #7
Prachi via AccessMonster.com
Guest
 
Posts: n/a
Default Re: Deleting records before import

Application:
Ok so this application generates (or prints word documents).
the data is mapped from queries written for this which further uses the
tables.
But i need to refresh this table from time to time (say a week) so as to
bring in fresh data to print reports.
So my first question where i had to automate deletion of tables instead of
manually selecting and deleting them was resolved by I the Use of a macro
and the DeleteObject command for deleting all the tables.I hope I am right.

Now my concern is how to automatically import the data at a press of a button.
when i use transfer database it gives me the error'Installed ISAM not found"
which i don not understand because the connection is ODBC connection,Please
can you help me here.

George Nicholson wrote:
>>>docmd.runsql ("delete * from name of the table you wanna empty")

>> So this will just delete the records from the local Access application
>> right?

>
>Well, *if* "name of table you wanna empy" is a local table, then yes, it
>will just delete local data.
>
>Also, keep in mind that instruction only empties *one* table, not all tables
>in the application
>
>If you want to empty more than one table, simply repeat that instruction as
>many as necessary.
>docmd.runsql ("delete * from table1")
>docmd.runsql ("delete * from table2")
>
>If you have enforced relationships between tables, you may have to do the
>deletes for that group of tables in a specific order (bottom of heirarchy to
>top)
>Reverse the order when filling those tables again (top of heirarchy to
>bottom).
>
>HTH,
>
>> thanks for replying..
>> So this will just delete the records from the local Access application

>[quoted text clipped - 16 lines]
>>>
>>>> Is it possible to delete all records (tables ) at the click of a button?


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Fo...odules/200708/1

  Reply With Quote
Reply



Thread Tools
Rate This Thread
Rate This Thread:

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 On
HTML code is Off