Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Adding time to a copied table

Posted on 2013-01-11
10
154 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using VB6 to write Excel Spreadsheets - 5 46
Chocolatey under PowerShell is not working properly 3 68
VBA taking too long 5 24
Limit the # times a macro code will run 14 50
This is an addendum to the following article: Acitve Directory based Outlook Signature (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_24950055.html) The script is fine, and works in normal client-server domains…
Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
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…

839 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