[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Adding time to a copied table

Posted on 2013-01-11
10
Medium Priority
?
158 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
[X]
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
  • 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 450 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 13

Assisted Solution

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

Assisted Solution

by:mbizup
mbizup earned 1050 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 1050 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 1050 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
Over the years I have built up my own little library of code snippets that I refer to when programming or writing a script.  Many of these have come from the web or adaptations from snippets I find on the Web.  Periodically I add to them when I come…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

649 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