Replacing a form on import

  • Thread starter Thread starter James
  • Start date Start date
J

James

I have this program that will import a backed-up table and it names it
"tblName1" and then you have to get rid of the old table and rename the
imported one to "tblName." How would I have the tblName imported after the
old table is renamed to "tblNameOld" and keep the name "tblName" Basically
I am trying to eliminate the use of the database window.


This is the current code:


Private Sub cmdImport_Click()
On Error GoTo ErrHandler
Dim clsImport As cBackupRestore
Dim strObjectName

Set clsImport = New cBackupRestore
With Me
If IsNull(.lbxFiles) Or IsNull(.lbxObjects) Then _
Err.Raise pconERR_BASE + 10
clsImport.FolderPath = .txtImportFolder
strObjectName = clsImport.ImportObject(.lbxObjects, _
.lbxFiles.Column(0), _
.lbxFiles.Column(1))
End With
MsgBox "Object " & pconQ & strObjectName & pconQ _
& " was restored successfully. Please call JimmieTech, Inc
816-668-4292 or e-mail: (e-mail address removed),for further assistance.",
vbInformation + vbOKOnly, _
"Restore Successful."
ExitHere:
Set clsImport = Nothing
Exit Sub
ErrHandler:
Select Case Err.Number
Case pconERR_BASE + 10:
MsgBox "Please make sure that you've selected " _
& vbCrLf & "both an Object Type and an Object to import." _
, vbExclamation + vbOKOnly, "Missing Information"
Case Else
MsgBox Err.Description & " (" & Err.Number _
& ")", vbCritical + vbOKOnly, "cmdImport_Click"
End Select
Resume ExitHere
End Sub
 
I have this program that will import a backed-up table and it names it
"tblName1" and then you have to get rid of the old table and rename the
imported one to "tblName." How would I have the tblName imported after the
old table is renamed to "tblNameOld" and keep the name "tblName" Basically
I am trying to eliminate the use of the database window.

DoCmd.DeleteObject acTable, "tblNameOld"
CurrentDb.TableDefs("tblName").Name = "tblNameOld"

Make sure you have proper error handling.

Peter
 
Back
Top