Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automation Error

Status
Not open for further replies.

BusMgr

IS-IT--Management
Joined
Aug 21, 2001
Messages
138
Location
US
In my database, I have a command button to create a dupicate database of my linked tables (the backend tables that are then relinked too.) There is a control to enter the new data base name and then click on the button to create the new file. The code is as follows:

Private Sub cmdCreateWellFile_Click()
On Error GoTo Err_cmdCreateWellFile_Click

Dim strBackEnd As String, dbname As String
Dim fsoFileSearch As FileSearch
Dim fs
Dim fld As String
Dim IntResponse As Integer

Set fs = CreateObject("Scripting.FileSystemObject")

fld = (GetDBDir(CurrentDb.Name))

'Set the path and name for the current database backend
strBackEnd = Right(CurrentDb.Name, Len(CurrentDb.Name) - Len(GetDBDir(CurrentDb.Name)))
strBackEnd = Left(strBackEnd, Len(strBackEnd) - 4) & "_be.mdb" 'Define source file name.

'See if the folder Job Folders exists

If fs.folderExists(fld & "Job Folder") Then 'Folder exists

Else 'Folder does not exist. Need to create it.

If MsgBox("Job Folder does not exist. Do you want to create it now?", vbYesNo) = vbYes Then
fs.CreateFolder (fld & "Job Folder")
FileCopy strBackEnd, fld & "Job Folder\" & strBackEnd 'Copy source to target.

Else

If MsgBox("You must create the folder Job Folder before you can continue!", vbOKOnly + vbCritical + vbDefaultButton1, "Create Folder") = vbOK Then
Forms!frmcreatewellfile!cmdCreateWellFile.SetFocus
End If

End If

End If

'Set the path and name for the new database

If Not IsNull(Me.txtWellID) Then

dbname = fld & "Job Folder\" & Me.txtWellID & ".mdb" 'Define target file name.

Else

If MsgBox("You must enter a WD & IS job number to create the well name", vbOKOnly, "Error - Job Number Required") = vbOK Then
Forms!frmcreatewellfile!txtWellID.SetFocus
Forms!frmcreatewellfile!txtWellID = ""

End If

End If

If dhFileExists(dbname) = True Then

IntResponse = MsgBox("File Already Exists", vbOKCancel + vbExclamation + vbDefaultButton1, "Error - Not New Job Number")

If (IntResponse = 1) Then

Forms!frmcreatewellfile!txtWellID.SetFocus
Forms!frmcreatewellfile!txtWellID = ""

ElseIf (IntResponse = 2) Then

DoCmd.Close acForm, Me.Form.Name 'Close the form

End If

Else
FileCopy strBackEnd, dbname 'Copy source to target.
DoCmd.Close acForm, Me.Form.Name 'Close the form

End If

Exit_cmdCreateWellFile_Click:
Exit Sub

Err_cmdCreateWellFile_Click:
MsgBox Err.Description
Resume Exit_cmdCreateWellFile_Click

End Sub

I have it working on several computers, but I have one client that I continually get the following error message:

Automation Error
The specified module could not be found. The code is dropping out at the line -
Set fs = CreateObject("Scripting.FileSystemObject")

I can load the same application on two computers side by side, mine works and my clients doesn't.

Any help is appreciated.

I have referenced the MS Office 9.0 Object Library.

 
You need to set the reference for the Microsoft Scripting Library.

HTH
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top