Solved

Copy and rename linked table to local table

Posted on 2014-02-15
2
366 Views
Last Modified: 2014-02-15
Hello~ I found the following code that very nicely copies and prompts the end user to enter a date that is included in the copied table's name. Because I am not familiar with VBA, can anyone assist in amending the following so that it will copy and prompt the end user for a date to be concatenated with the table name but for a linked table to a local table:

Dim strOldTable As String
Dim strPrompt As String

strPrompt = InputBox("Enter date table is copied")
DoCmd.CopyObject , "Test Table" & "_" & strPrompt, acTable, "Test Table"

The result is "Test Table_2/15/14" (or whatever date the end user enters).  Any help is great appreciated.
0
Comment
Question by:jaguar5554
2 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 39861997
your code looks ok.
are you getting any problem, error?


here is an alternative code, using create a new table

Dim strOldTable As String, strNewtable
Dim strPrompt As String
strOldTable = "Test Table"
strPrompt = InputBox("Enter date table is copied")
strNewtable = strOldTable & "_" & strPrompt

CurrentDb.Execute "Select [" & strOldTable & "].* INTO [" & strNewtable & "]" _
        & " From [" & strOldTable & "]"
0
 

Author Closing Comment

by:jaguar5554
ID: 39862051
That works beautifully! To answer yours -- the original code worked fine; however, it created another linked file. Your code copies the linked table to a local table -- along with a prompt to rename/date the copy. That's just what I needed. Thank you much!
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

830 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