In Need of Help...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am after creating a macro that will copy a table structure and paste a copy
into the same database but then ask the user to Name the Copy which has just
been created.

Is there a way i can do this in VBA?

Regards
 
Access said:
Is there a way i can do this in VBA?

Create a new button and paste this into the click event:

On Error GoTo ProcErr

Dim sNewName As String
Const TABLENAME As String = "NewTable"

sNewName = InputBox("Please type a new table name:", "Copy Table",
TABLENAME)
If (Len(sNewName) = 0) Then
sNewName = TABLENAME
End If

DoCmd.CopyObject , sNewName, acTable, "YourTableName"

Exit Sub

ProcErr:
If (Err.Number <> 2501) Then
MsgBox Err.Number & vbCrLf & Err.Description
End If
Err.Clear
 
Back
Top