Link to home
Start Free TrialLog in
Avatar of donnie91910
donnie91910

asked on

Adding time to a copied table

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
Avatar of donnie91910
donnie91910

ASKER

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).
SOLUTION
Avatar of Member_2_861731
Member_2_861731
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I when I add the time I get the message:
Run-time error '3067':
Query input must contain at least one table or query.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
On the "End With" statement, I get the following error:

Compile Error:

Expected End Function
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
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
This works.