K
Kitty
I have the following code behind a form (this is an
excerpt). This code creates a temporary database on a
drive the user has selected earlier in the process. That
drive letter is saved in a table as it will be used
multiple times.
The references to the diskette drive are hard coded as a
different message is used if the temporary database
exists. My problem is with other drives. Apparently
the .LookIn procedure cannot be fed a variable? If I hard
code another drive letter, the rename process works. If I
feed it the variable, I get an invalid procedure call
error.
Any suggestions??
Thank you for your help.
With Application.FileSearch 'looks to see if the
temp.mdb already exists
If TransferDrive = "A" Then
.LookIn = "A:\"
.FileName = "Temp.mdb"
If .Execute = 0 Then 'file doesn't exist
GoTo Continue
Else
MsgBox "The temp file already exists. Insert
another diskette.", vbOKOnly, "Insert New Diskette"
GoTo ExitHere
End If
Else
.LookIn = TransferDrive & "\:"
.FileName = "Temp.mdb"
If .Execute = 0 Then
GoTo Continue
Else
Name TransferDrive & "\:Temp.mdb" As
TransferDrive & "\:" & ASSN & "RenamedTemp.mdb"
MsgBox "A temp file was found on this drive.
It has been named 'RenamedTemp.mdb.'",
vbOKOnly, "Duplicate Database"
GoTo Continue
End If
End If
End With
Continue:
Set dbsMYDB = MYWS.CreateDatabase(TransferDrive
& ":\TEMP.MDB", dbLangGeneral)
DoCmd.CopyObject TransferDrive
& ":\temp.mdb", "tblSample", acTable, "tblSampleOrig"
MsgBox "The temp.mdb database has been created.",
vbOKOnly, "Done"
excerpt). This code creates a temporary database on a
drive the user has selected earlier in the process. That
drive letter is saved in a table as it will be used
multiple times.
The references to the diskette drive are hard coded as a
different message is used if the temporary database
exists. My problem is with other drives. Apparently
the .LookIn procedure cannot be fed a variable? If I hard
code another drive letter, the rename process works. If I
feed it the variable, I get an invalid procedure call
error.
Any suggestions??
Thank you for your help.
With Application.FileSearch 'looks to see if the
temp.mdb already exists
If TransferDrive = "A" Then
.LookIn = "A:\"
.FileName = "Temp.mdb"
If .Execute = 0 Then 'file doesn't exist
GoTo Continue
Else
MsgBox "The temp file already exists. Insert
another diskette.", vbOKOnly, "Insert New Diskette"
GoTo ExitHere
End If
Else
.LookIn = TransferDrive & "\:"
.FileName = "Temp.mdb"
If .Execute = 0 Then
GoTo Continue
Else
Name TransferDrive & "\:Temp.mdb" As
TransferDrive & "\:" & ASSN & "RenamedTemp.mdb"
MsgBox "A temp file was found on this drive.
It has been named 'RenamedTemp.mdb.'",
vbOKOnly, "Duplicate Database"
GoTo Continue
End If
End If
End With
Continue:
Set dbsMYDB = MYWS.CreateDatabase(TransferDrive
& ":\TEMP.MDB", dbLangGeneral)
DoCmd.CopyObject TransferDrive
& ":\temp.mdb", "tblSample", acTable, "tblSampleOrig"
MsgBox "The temp.mdb database has been created.",
vbOKOnly, "Done"