PC Review


Reply
Thread Tools Rate Thread

Can I make DoCmd.TransferText to replace existing table?

 
 
Sirritys
Guest
Posts: n/a
 
      11th Oct 2006
I'm tryingto replace tables when importing, but instead the
"DoCmd.TransferText" just appends the data after existing data in
existing table.

How could I make it to replace the whole table.

If this is not possible, how can I delete tables with VBA?

Sincerelly yours,
Sirritys

 
Reply With Quote
 
 
 
 
Nikos Yannacopoulos
Guest
Posts: n/a
 
      11th Oct 2006
DoCmd.DeleteObject acTable, "MyTable"

HTH,
Nikos
 
Reply With Quote
 
Sirritys
Guest
Posts: n/a
 
      11th Oct 2006
Thank you!

 
Reply With Quote
 
Nikos Yannacopoulos
Guest
Posts: n/a
 
      11th Oct 2006
I should have said this in the first instance... this kind of operation
is expected to result in significant database bloat, so you better make
sure you compact regularly! If this is a monolithic database, setting
the Compact On Close option (Tools > Options, tab "General") will do it
just fine.

On second thought, you could achieve the same result by just deleting
all records from the table rather than the table itself:

CUrrentDb.Execute "DELETE * FROM MyTable", dbFailOnError

I suspect this might result in somewhat less bloat, especially for small
tables (few records), but you'll still need to compact regularly; if the
record numbers are high, the difference in bloat would be insignificant.

Nikos
 
Reply With Quote
 
Sirritys
Guest
Posts: n/a
 
      12th Oct 2006
Hi again,

I am still wondering that if I use this method how am I able to insert
variable name on the place of "MyTable", since the whole command is
inside of " " ?



>
> CUrrentDb.Execute "DELETE * FROM MyTable", dbFailOnError
>


 
Reply With Quote
 
Nikos Yannacopoulos
Guest
Posts: n/a
 
      12th Oct 2006
You can concatenate test strings with variable values in code:

MyVariable = "Some Value"
strSomething = "Some Text " & MyVariable

so in the first line you assign value SomeValue to variable MyVariable;
in the second one, you concatenate a text string and the value in
MyVariable, so the value of strSomething becomes:
"Some Text Some Value"

Likewise:

strTable = "SomeTableName"
strSQL = "DELETE * FROM " & strTable
CurrentDb.Execute strSQL, dbFailOnError

I hope this is clear.

Nikos
 
Reply With Quote
 
Sirritys
Guest
Posts: n/a
 
      18th Oct 2006
Thanks man, didn't thought it that way =). Whould have realised that on
my own ;-(


Nikos Yannacopoulos wrote:
> You can concatenate test strings with variable values in code:
>
> MyVariable = "Some Value"
> strSomething = "Some Text " & MyVariable
>
> so in the first line you assign value SomeValue to variable MyVariable;
> in the second one, you concatenate a text string and the value in
> MyVariable, so the value of strSomething becomes:
> "Some Text Some Value"
>
> Likewise:
>
> strTable = "SomeTableName"
> strSQL = "DELETE * FROM " & strTable
> CurrentDb.Execute strSQL, dbFailOnError
>
> I hope this is clear.
>
> Nikos


 
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Docmd.TransferText fails to create new table Rich K Microsoft Access External Data 4 24th Jul 2008 11:27 PM
Access 2003 conversion docmd.transfertext to linked table =?Utf-8?B?VG9ueSBM?= Microsoft Access 1 12th Apr 2007 11:02 PM
PowerPoint. How to make a new line of text replace an existing one =?Utf-8?B?c1RFUEhFTiBrQVBFTE9X?= Microsoft Powerpoint 1 7th May 2005 12:57 AM
How do I make Word 2003 ask if I want to replace existing file? =?Utf-8?B?Zm9yZXN0YmlsdA==?= Microsoft Word Document Management 6 8th Mar 2005 03:59 PM
DoCmd.TransferText Steven M. Britton Microsoft Access Form Coding 8 9th Nov 2003 08:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:08 PM.