Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save table with new name

Status
Not open for further replies.

TooNew

Programmer
Aug 29, 2003
23
0
0
US
I need code to open a table identified by user
ie. [Forms]![DataInput].[TableSelected]) and save it with a new name ie. "BillingInput".

I can open the table, select the table, but can't find how to save it with a new name without using acCmdSaveAs which requires user to enter the new name. It seems like it should be an easy task, but I not getting anywhere and can't locate an existing solution in the fourms. Thanks for any help.
 
I think you'll have to use VBA to do it.
Create an tabledefs object
Create a table object and "SET" it to your table
Change the Name property
Then use the tabledefs UPDATE method

JHall
 
Hi TooNew,

There are two different scenarios that are possible and I am not sure which one you are looking for so I will include both of them for you.

1)Renaming Table:
DoCmd.Rename [Forms]![DataInput].[TableSelected]), acTable, "Billing Info"

2)Save a new table with new name without deleting old:
DoCmd.CopyObject , "Billing Info", acTable, [Forms]![DataInput].[TableSelected])

Let me know if this helps.

Regards,
gkprogrammer
 
Hello Again,

I just noticed upon reviewing the above post that I submitted that a parenthesis is incorreclty added after the following line [Forms]![DataInput].[TableSelected]. Please be sure not to include that in the code I have supplied, when I copied this naming convention from your above post it included this parenthesis, just so know.


Regards,
gkprogrammer
 
Thanks everyone. I can't believe I missed the doCmd.Rename . I did try the doCmd.CopyObject previsously but did something wrong and generated an error.
Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top