Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Copy and rename linked table to local table

Posted on 2014-02-15
2
Medium Priority
?
416 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
[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
2 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 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

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

721 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