Solved

Copy and rename linked table to local table

Posted on 2014-02-15
2
352 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 119

Accepted Solution

by:
Rey Obrero earned 500 total points
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now