In Need of Help...

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
 
G

Granny Spitz via AccessMonster.com

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top