By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,398 Members | 989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,398 IT Pros & Developers. It's quick & easy.

Check Date of Table

P: 2
I am trying to import a paradox table into an access database. I need to do this daily as I get a download of this file everyday. I want to do this on startup of a form.

How can I check the date of the imported table and if it not the current date then update it.

Something like this:

Look at table "balances"
If date of "balances" table in current access db is not today
delete current table "balances"
docmd transferdatabase paradox "balances"
else
do nothing

I think I can write the code to import, it is the date checking that I have no clue where to start.

Thanks in advance.
Sep 5 '07 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 126
This depends (slightly) on how you store the date (which, if you are not doing, you will have to do).
Ideally you have some other table, eg. UPDATE(date, table_name) that you can reference, because otherwise you have to store a field in every record, eg. date_added. If you do the second (or either for that matter, just replace the table and field names in the following line of code), you can use DCOUNT. Now, I've assumed that you do actually want to delete the table here (not just delete the rows from it - quite a difference so if I'm wrong, don't run this code, tell me and I'll modify it).
Expand|Select|Wrap|Line Numbers
  1. IF DCount("*","balances","the_field_with_the_date_stored = #" & date() & "#") = 0 then
  2.     DoCmd.runSQL("DROP TABLE balances;") 'not tested, but double checked on google.
  3.     docmd transferdatabase paradox "balances" 'whatever you want to put here
  4. End If 'No point having an Else do nothing, because without the Else, nothing would have been done.
  5.  
Hope this helps, but it is not tested at all.
Sep 5 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.