PC Review


Reply
Thread Tools Rate Thread

Can't kill 'e can't live with 'em.

 
 
Hydra
Guest
Posts: n/a
 
      17th Jun 2009
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.


 
Reply With Quote
 
 
 
 
JLGWhiz
Guest
Posts: n/a
 
      17th Jun 2009
Try it this way:

If Not Dir(strDB) Is NothingThen



"Hydra" <(E-Mail Removed)> wrote in message
news:1C41B05C-8E55-49F5-A582-(E-Mail Removed)...
> 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.
>
>



 
Reply With Quote
 
Hydra
Guest
Posts: n/a
 
      18th Jun 2009
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" <(E-Mail Removed)> wrote in message
> news:1C41B05C-8E55-49F5-A582-(E-Mail Removed)...
> > 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.
> >
> >

>
>
>

 
Reply With Quote
 
JLGWhiz
Guest
Posts: n/a
 
      18th Jun 2009
I just ran this, and it deleted the file. The two message boxes are
trouble shooting tools and can be deleted or ignored. It is basically the
same code that you initially posted, so it could be that someone had the
file open. Or maybe you had the file open. It will not delete an open
file.

Sub dk()
myPath = ThisWorkbook.Path
fl = myPath & "\test.xls"
If Dir(fl) <> "" Then
MsgBox "It's There"
MsgBox Dir(fl)
Kill fl
End If
End Sub

And yes, the syntax using the Not operator will not work for this
application. I leaped before I looked on that one.


"Hydra" <(E-Mail Removed)> wrote in message
news:CD28C9FF-96E2-4AD5-AE9E-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
>> news:1C41B05C-8E55-49F5-A582-(E-Mail Removed)...
>> > 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.
>> >
>> >

>>
>>
>>



 
Reply With Quote
 
Patrick Molloy
Guest
Posts: n/a
 
      18th Jun 2009
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" <(E-Mail Removed)> wrote in message
news:CD28C9FF-96E2-4AD5-AE9E-(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
>> news:1C41B05C-8E55-49F5-A582-(E-Mail Removed)...
>> > 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.
>> >
>> >

>>
>>
>>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to use pskill or kill ... to kill a process with a name like "Hello There" flahmeshess Microsoft Windows 2000 9 27th Oct 2009 06:13 AM
Kill TS Client... Kill, Kill hamishmurphy@gmail.com Microsoft Dot NET Compact Framework 1 5th Jul 2006 04:48 PM
Process.Kill:How to kill an attached debugger? Manfred Braun Microsoft C# .NET 1 16th Aug 2005 08:53 PM
RE: RISE OF NATIONS--when playing conquer the world campaign i am unable to kill enemy spies. after hours spent searching manual, and various sites i can find no mention of HOW TO KILL SPIES =?Utf-8?B?Sko=?= Windows XP Games 0 1st Apr 2004 03:56 AM
How to kill a child process when kill the parent process lynn Microsoft Dot NET 0 31st Jul 2003 04:12 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:13 PM.