Solved

Adding time to a copied table

Posted on 2013-01-11
10
152 Views
Last Modified: 2013-03-29
I want to add the current time to the end of the table that I am selecting into.  Right now I am only adding the date which comes out as: MyTable_20130111.  I would like it to have the date on the end as:
MyTable_20130111_10:38:00 PM.
Here is my code that I have now:
Function BkupLastEntry()
With DoCmd
    .SetWarnings False
    .RunSQL "SELECT * INTO MyTable_" & Format(Now, "yyyymmdd") & " FROM MyTable_EXTRACT"
    .SetWarnings True
End With
0
Comment
Question by:donnie91910
  • 5
  • 3
  • 2
10 Comments
 

Author Comment

by:donnie91910
ID: 38768269
I would like it to have the date on the end as:
MyTable_20130111_10:38:00 PM. (or whatever time that it is at the time of the copy).
0
 
LVL 13

Assisted Solution

by:LIONKING
LIONKING earned 150 total points
ID: 38768342
Have you tried something like:

Format(Now, "yyyyMMdd hh:mm:ss tt")
0
 

Author Comment

by:donnie91910
ID: 38768492
I when I add the time I get the message:
Run-time error '3067':
Query input must contain at least one table or query.
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 13

Assisted Solution

by:LIONKING
LIONKING earned 150 total points
ID: 38768497
Can you post your code to take a look at it?
0
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 350 total points
ID: 38768795
See if this makes a difference... it is probably choking on the punctuation (Access is picky about special characters in your object names).

Function BkupLastEntry()
With DoCmd
    .SetWarnings False
    .RunSQL "SELECT * INTO MyTable_" & Format(Now, "yyyymmdd_hhnnssAMPM") & " FROM MyTable_EXTRACT"
    .SetWarnings True
End With

Open in new window

0
 
LVL 61

Accepted Solution

by:
mbizup earned 350 total points
ID: 38768816
If you must have some kind of delimiter to break up your timestamp, use an underscore instead of a colon:

Function BkupLastEntry()
With DoCmd
    .SetWarnings False
    .RunSQL "SELECT * INTO MyTable_" & Format(Now, "yyyymmdd_hh_nn_ss_AMPM") & " FROM MyTable_EXTRACT"
    .SetWarnings True
End With

Open in new window

0
 

Author Comment

by:donnie91910
ID: 38870508
On the "End With" statement, I get the following error:

Compile Error:

Expected End Function
0
 

Author Comment

by:donnie91910
ID: 38872218
Will this code work with Access 2007?
Function BkupLastEntry()
With DoCmd
    .SetWarnings False
    .RunSQL "SELECT * INTO MyTable_" & Format(Now, "yyyymmdd_hh_nn_ss_AMPM") & " FROM MyTable_EXTRACT"
    .SetWarnings True
End With
0
 
LVL 61

Assisted Solution

by:mbizup
mbizup earned 350 total points
ID: 38873017
There is nothing version specific in that code so it should work in any version of Access.
0
 

Author Closing Comment

by:donnie91910
ID: 39032379
This works.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question