Overwriting a table

  • Thread starter Thread starter Gringarlow
  • Start date Start date
G

Gringarlow

I have a table of daily data, lets call it tblDAILY-DATA, that I import from
a website. This data does not have a date on it. I take the tblDAILY-DATA and
run a make table query that adds the date, DATE()-1, it is yesterdays data,
and I call this new table tblDAILY-DATA1. Now, what I don't know how to do is
import data tomorrow that will overwrite the original table, tblDAILY-DATA.
So when IO run the make table query it will only add the new data to
tblDAILY-DATA1.
Thank You
 
If you don't need to keep the tblDAILY-DATA with data in it why not just run
a code that will delete the table and create a new one with the same name -
there are lots of simple code that will do this

Can you give more details

Also I would not run a make table - if you "do" want to keep the data - just
use an update query with a calculated column - either set to today-1 or just
Date()
You could also run an appeand query (maybe the same on) to just add new data
to the table
 
I'll try this first, delete the table and importing a new one each day. Then
all I need to do is append the table each day

Thank You
 
This should help you to delete the table and then reimport it again


Dim db As Database, tdf As TableDef
Set db = CurrentDb()
For Each tdf In db.TableDefs
If tdf.Name = "tblDAILY-DATA" Then
DoCmd.DeleteObject acTable, ""
End If
Next
DoCmd.TransferDatabase acImport, "Microsoft Access", "Path to DB.mdb",
acTable, "tblDAILY-DATA", "tblDAILY-DATA", structureonly:=False
End Sub


Of course add the full path in the code where it says Path to DB.mdb
something like this
C:\Documents and Settings\MyDocument\MyTable.mdb",

Oh and if your table is not called tblDAILY-DATA in your on-line DB then you
can just add the new name in the last line of the code (which all goes on one
line by the way)

Hope this helps
 
Back
Top