View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Patrick Molloy Patrick Molloy is offline
external usenet poster
 
Posts: 1,049
Default Can't kill 'e can't live with 'em.

if the first IF/End If deletes the file if it exists, and then the second
block of code tries to open the file, so it must fail....hence the error.


"Hydra" wrote in message
...
This threw a type mismatch error ???

strDB is Dim as string and contains the name of a valid path.



"JLGWhiz" wrote:

Try it this way:

If Not Dir(strDB) Is NothingThen



"Hydra" wrote in message
...
If Dir(strDB) < "" Then
Kill strDB
End If

Set AppAccess = CreateObject("Access.Application")
AppAccess.Visible = True
AppAccess.OpenCurrentDatabase strDB
AppAccess.DoCmd.Opentable "MSP Data", acViewNormal, acAdd

---------------------------------------------

Throws an Error cannot open the database because it is missing or opend
exclusively by another user


-------------------------------------------


If Dir("C:\DataCheck.mdb") < "" Then
MsgBox "Datacheck Exists"
Kill "C:\DataCheck.mdb"
End If
Set appAccess = CreateObject("Access.Application")
appAccess.Visible = True
With appAccess
.NewCurrentDatabase ("C:\DataCheck.mdb")
.Visible = True

---------------------------------------------
Throws an error saying there is an existing database with this name,
choose
another name.