469,126 Members | 1,277 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,126 developers. It's quick & easy.

Rename Table to what is in textbox

Alireza355
I want to know how to rename a table to what is in a textbox in an unbound form.

For example: Text1=abcd

I want to rename Table1 to abcd

I know I can do this:

DoCmd.CopyObject , "abcd", acTable, "Table1"
DoCmd.DeleteObject acTable, "Table1"


But how to rename the table to the textbox contents??????????

Thanx.
Mar 4 '09 #1
3 2085
ADezii
8,800 Expert 8TB
@Alireza355
This would be the basic code. This code does not, however, check for the existence of either the Source or Copied Tables:
Expand|Select|Wrap|Line Numbers
  1. Dim ctl As TextBox
  2.  
  3. Set ctl = Me![Text1]
  4.  
  5. If Not IsNull(ctl) Then
  6.   DoCmd.Rename ctl, acTable, "Table1"
  7.     RefreshDatabaseWindow
  8. Else
  9.   MsgBox "No Table Name entered in Text1!", vbExclamation, "No Name Entered"
  10. End If
Mar 4 '09 #2
Wow, Thanx a lot for your kind help.

Best Regards,
Alireza355
Mar 4 '09 #3
ADezii
8,800 Expert 8TB
@Alireza355
You are quite welcome.
Mar 5 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by TroelsM | last post: by
2 posts views Thread by Paul Casner | last post: by
1 post views Thread by gaozj111 | last post: by
1 post views Thread by solar | last post: by
1 post views Thread by Carl Pearson | last post: by
1 post views Thread by cheesey_toastie | last post: by
1 post views Thread by Gladiator | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.