Use Command button to rename on fly

  • Thread starter Thread starter Kellie
  • Start date Start date
K

Kellie

I am trying to get a command button to do a rename,
however, I do not want to have a pre-determined name...I
want to choose the name on the fly.

Ex. I know you can do a rename by doing an [Event
Procedure]...
DoCmd.Rename "New Name", acTable, "Old Name"

I do not want to pick the new name. I want a box to come
up and the user will type in the name they want the table
to change to.

Is this possible????
Thank You
 
Kellie said:
I am trying to get a command button to do a rename,
however, I do not want to have a pre-determined name...I
want to choose the name on the fly.

Ex. I know you can do a rename by doing an [Event
Procedure]...
DoCmd.Rename "New Name", acTable, "Old Name"

I do not want to pick the new name. I want a box to come
up and the user will type in the name they want the table
to change to.

Is this possible????
Thank You

You could use something along these lines:

Dim strNewNama As String

strNewName = InputBox("Enter a new name:")

If Len(strNewName) > 0 Then
DoCmd.Rename strNewName, acTable, "Old Name"
End If

Of course, that will raise an error if the new name already exists.
 
Hi,

You could use the InputBox function.

Code would have to make sure that a name is entered:

Dim strName As String
strName = ""
Do Until Len(strName) > 0
strName = InputBox("Please Enter the new table name", _
"Rename Example", "tblSomeTable")
Loop
DoCmd.Rename strName, acTable, "tblSomeTable"

HTH

--

Cheers
Mark

Free Access/Office Add-Ins at:
http://mphillipson.users.btopenworld.com/
 
Back
Top