Connecting Tech Pros Worldwide Help | Site Map

Determine if A: drive is empty

Chuck
Guest
 
Posts: n/a
#1: Nov 13 '05
I have a macro that saves data to an A: drive. If the drive is empty and I run
the macro, the drive clicks a few times, and a message comes up saying "the
file already exists, do I want to over write it. I figure this is going to be
a neat trick, so I click yes with the drive still empty. A message comes
saying access can't write to the file. I click OK and a window opens showing
that the macro has failed and gives me a chance to halt it.

I would like to have the macro check to see if there is a floppy inplace before
it tries to write data. I'm only a wizzard prodder, so if this requires
special code, I'll need very explicit help.

However, any suggestions will be greatfull receiver.

Chuck
....
Wayne Morgan
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Determine if A: drive is empty


My recommendation would be to use VBA instead of the macro. Copying the file
using VBA will allow you to trap the error in the error handler, such as
this

'Error 52 is generated if no floppy is in the drive when doing a Dir
If Err.Number = 52 Then
msg = "Please insert a formatted disk in the A: drive!" & vbCrLf &
"Click Ok when ready."
RetVal = MsgBox(msg, vbCritical + vbOKCancel, "Insert Floppy")
If RetVal = vbCancel Then Resume CleanUp
Resume TryAgain
End If
If Err.Number = 3026 Then
msg = "Disk is full! Please insert a floppy with at least 60k of empty
space."
RetVal = MsgBox(msg, vbCritical + vbOKCancel, "Insert Floppy")
If RetVal = vbCancel Then Resume CleanUp
Resume TryAgain
End If

--
Wayne Morgan
MS Access MVP


"Chuck" <libbeyc@schoollink.net> wrote in message
news:847ig0dhrjaqrk117um70a661aksd43do1@4ax.com...[color=blue]
> I have a macro that saves data to an A: drive. If the drive is empty and[/color]
I run[color=blue]
> the macro, the drive clicks a few times, and a message comes up saying[/color]
"the[color=blue]
> file already exists, do I want to over write it. I figure this is going[/color]
to be[color=blue]
> a neat trick, so I click yes with the drive still empty. A message comes
> saying access can't write to the file. I click OK and a window opens[/color]
showing[color=blue]
> that the macro has failed and gives me a chance to halt it.
>
> I would like to have the macro check to see if there is a floppy inplace[/color]
before[color=blue]
> it tries to write data. I'm only a wizzard prodder, so if this requires
> special code, I'll need very explicit help.
>
> However, any suggestions will be greatfull receiver.
>
> Chuck
> ...[/color]


James Fortune
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Determine if A: drive is empty


Chuck <libbeyc@schoollink.net> wrote in message news:<847ig0dhrjaqrk117um70a661aksd43do1@4ax.com>. ..[color=blue]
> I have a macro that saves data to an A: drive. If the drive is empty and I run
> the macro, the drive clicks a few times, and a message comes up saying "the
> file already exists, do I want to over write it. I figure this is going to be
> a neat trick, so I click yes with the drive still empty. A message comes
> saying access can't write to the file. I click OK and a window opens showing
> that the macro has failed and gives me a chance to halt it.
>
> I would like to have the macro check to see if there is a floppy inplace before
> it tries to write data. I'm only a wizzard prodder, so if this requires
> special code, I'll need very explicit help.
>
> However, any suggestions will be greatfull receiver.
>
> Chuck
> ...[/color]

Recently, I have been trying to find ways to avoid relying on Access'
error handler mechanism in an effort to catch more errors before they
happen. In

http://groups.google.com/groups?hl=e....8D6%40hlp.com

Andrew Kennedy gives an assembly language routine to check for the
presence of a disk in the floppy drive without using interrupt 24.

In

http://groups.google.com/groups?hl=e...40nntp.crl.com

Weiqi Gao says:

That leaves us with only two options: create a dll file using assember
and call the functions from Access Basic, --OR-- embed _asm{...} in a
C function and compile it to a dll.

Has anyone created such a dll already that deals with floppy
information?

Thanks,
James A. Fortune
Wayne Morgan
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Determine if A: drive is empty


Yes, Microsoft has. See if this helps. It is for VB but should be able to be
ported to Access with a couple of minor changes (namely the control array on
the form).

http://vbnet.mvps.org/index.html?cod...loppyready.htm

--
Wayne Morgan
MS Access MVP


"James Fortune" <jafortun@oakland.edu> wrote in message
news:a6ed3ce7.0407291609.59db5f6d@posting.google.c om...[color=blue]
> Chuck <libbeyc@schoollink.net> wrote in message[/color]
news:<847ig0dhrjaqrk117um70a661aksd43do1@4ax.com>. ..[color=blue][color=green]
> > I have a macro that saves data to an A: drive. If the drive is empty[/color][/color]
and I run[color=blue][color=green]
> > the macro, the drive clicks a few times, and a message comes up saying[/color][/color]
"the[color=blue][color=green]
> > file already exists, do I want to over write it. I figure this is going[/color][/color]
to be[color=blue][color=green]
> > a neat trick, so I click yes with the drive still empty. A message[/color][/color]
comes[color=blue][color=green]
> > saying access can't write to the file. I click OK and a window opens[/color][/color]
showing[color=blue][color=green]
> > that the macro has failed and gives me a chance to halt it.
> >
> > I would like to have the macro check to see if there is a floppy inplace[/color][/color]
before[color=blue][color=green]
> > it tries to write data. I'm only a wizzard prodder, so if this requires
> > special code, I'll need very explicit help.
> >
> > However, any suggestions will be greatfull receiver.
> >
> > Chuck
> > ...[/color]
>
> Recently, I have been trying to find ways to avoid relying on Access'
> error handler mechanism in an effort to catch more errors before they
> happen. In
>
>[/color]
http://groups.google.com/groups?hl=e....8D6%40hlp.com[color=blue]
>
> Andrew Kennedy gives an assembly language routine to check for the
> presence of a disk in the floppy drive without using interrupt 24.
>
> In
>
>[/color]
http://groups.google.com/groups?hl=e...40nntp.crl.com[color=blue]
>
> Weiqi Gao says:
>
> That leaves us with only two options: create a dll file using assember
> and call the functions from Access Basic, --OR-- embed _asm{...} in a
> C function and compile it to a dll.
>
> Has anyone created such a dll already that deals with floppy
> information?
>
> Thanks,
> James A. Fortune[/color]


James Fortune
Guest
 
Posts: n/a
#5: Nov 13 '05

re: Determine if A: drive is empty


"Wayne Morgan" <comprev_gothroughthenewsgroup@hotmail.com> wrote in message news:<RKgOc.451$ID7.278@newssvr24.news.prodigy.com >...[color=blue]
> Yes, Microsoft has. See if this helps. It is for VB but should be able to be
> ported to Access with a couple of minor changes (namely the control array on
> the form).
>
> http://vbnet.mvps.org/index.html?cod...loppyready.htm
>
> --
> Wayne Morgan
> MS Access MVP[/color]

It's nice to know that there's at least one way to use API functions
to do it. Given the claim that MicroSoft's FileSystemObject is not
totally reliable, I'll have to decide whether to create my own dll,
use Randy Birch's solution, or cook up my own API solution in case I
need to distribute it. Again, has anyone created their own dll that
gets around the limitations of the FileSystemObject?

James A. Fortune
B. Austin
Guest
 
Posts: n/a
#6: Nov 13 '05

re: Determine if A: drive is empty


I missed the first part of this thread, but doesn't the following function do what is required?

Function udfFileExists(varFileName As Variant) As Boolean

On Error GoTo Err_udfFileExists

Open varFileName For Input As #1

Close #1

udfFileExists = True

udfFileExists_Exit:

Exit Function

Err_udfFileExists:

Beep

Select Case Err
Case 53, 68, 75, 76
MsgBox "FILE '" & varFileName & "' NOT FOUND.", vbCritical
Case 71
MsgBox "DEVICE IS NOT READY.", vbCritical
Case Else
MsgBox _
"AN ERROR OCCURRED." & vbCrLf & vbCrLf & _
"Error Number: " & Err.Number & vbCrLf & vbCrLf & _
"Description: " & Err.Description, vbCritical
End Select

udfFileExists = False

Resume udfFileExists_Exit

End Function


On 1 Aug 2004 12:17:38 -0700, jafortun@oakland.edu (James Fortune) wrote:
[color=blue]
>"Wayne Morgan" <comprev_gothroughthenewsgroup@hotmail.com> wrote in message news:<RKgOc.451$ID7.278@newssvr24.news.prodigy.com >...[color=green]
>> Yes, Microsoft has. See if this helps. It is for VB but should be able to be
>> ported to Access with a couple of minor changes (namely the control array on
>> the form).
>>
>> http://vbnet.mvps.org/index.html?cod...loppyready.htm
>>
>> --
>> Wayne Morgan
>> MS Access MVP[/color]
>
>It's nice to know that there's at least one way to use API functions
>to do it. Given the claim that MicroSoft's FileSystemObject is not
>totally reliable, I'll have to decide whether to create my own dll,
>use Randy Birch's solution, or cook up my own API solution in case I
>need to distribute it. Again, has anyone created their own dll that
>gets around the limitations of the FileSystemObject?
>
>James A. Fortune[/color]

(Remove NOSPAM to reply.)
Michael \(michka\) Kaplan [MS]
Guest
 
Posts: n/a
#7: Nov 13 '05

re: Determine if A: drive is empty


I believe you may have problems with the OS putting up errors about there
being no disk -- the code that was posted works around that problem....

--
MichKa [MS]
NLS Collation/Locale/Keyboard Development
Globalization Infrastructure and Font Technologies
Windows International Division

This posting is provided "AS IS" with
no warranties, and confers no rights.


"B. Austin" <baustin2NOSPAM@aol.com> wrote in message
news:e2iqg0t3psahoje4k8r7r4pchbh05por38@4ax.com...[color=blue]
> I missed the first part of this thread, but doesn't the following function[/color]
do what is required?[color=blue]
>
> Function udfFileExists(varFileName As Variant) As Boolean
>
> On Error GoTo Err_udfFileExists
>
> Open varFileName For Input As #1
>
> Close #1
>
> udfFileExists = True
>
> udfFileExists_Exit:
>
> Exit Function
>
> Err_udfFileExists:
>
> Beep
>
> Select Case Err
> Case 53, 68, 75, 76
> MsgBox "FILE '" & varFileName & "' NOT FOUND.", vbCritical
> Case 71
> MsgBox "DEVICE IS NOT READY.", vbCritical
> Case Else
> MsgBox _
> "AN ERROR OCCURRED." & vbCrLf & vbCrLf & _
> "Error Number: " & Err.Number & vbCrLf & vbCrLf & _
> "Description: " & Err.Description, vbCritical
> End Select
>
> udfFileExists = False
>
> Resume udfFileExists_Exit
>
> End Function
>
>
> On 1 Aug 2004 12:17:38 -0700, jafortun@oakland.edu (James Fortune) wrote:
>[color=green]
> >"Wayne Morgan" <comprev_gothroughthenewsgroup@hotmail.com> wrote in[/color][/color]
message news:<RKgOc.451$ID7.278@newssvr24.news.prodigy.com >...[color=blue][color=green][color=darkred]
> >> Yes, Microsoft has. See if this helps. It is for VB but should be able[/color][/color][/color]
to be[color=blue][color=green][color=darkred]
> >> ported to Access with a couple of minor changes (namely the control[/color][/color][/color]
array on[color=blue][color=green][color=darkred]
> >> the form).
> >>
> >> http://vbnet.mvps.org/index.html?cod...loppyready.htm
> >>
> >> --
> >> Wayne Morgan
> >> MS Access MVP[/color]
> >
> >It's nice to know that there's at least one way to use API functions
> >to do it. Given the claim that MicroSoft's FileSystemObject is not
> >totally reliable, I'll have to decide whether to create my own dll,
> >use Randy Birch's solution, or cook up my own API solution in case I
> >need to distribute it. Again, has anyone created their own dll that
> >gets around the limitations of the FileSystemObject?
> >
> >James A. Fortune[/color]
>
> (Remove NOSPAM to reply.)[/color]


B. Austin
Guest
 
Posts: n/a
#8: Nov 13 '05

re: Determine if A: drive is empty


Mich -

Thanks for the heads up.

Always looking for opportunities to improve my code. What circumstances would cause the OS to raise
an error that would get past the 'FileExists' function? (I missed the early parts of this thread.)

TIA.

- Brian

On Sun, 1 Aug 2004 17:27:30 -0700, "Michael \(michka\) Kaplan [MS]" <michkap@online.microsoft.com>
wrote:
[color=blue]
>I believe you may have problems with the OS putting up errors about there
>being no disk -- the code that was posted works around that problem....[/color]

(Remove NOSPAM to reply.)
James Fortune
Guest
 
Posts: n/a
#9: Nov 13 '05

re: Determine if A: drive is empty


B. Austin <baustin2NOSPAM@aol.com> wrote in message news:<e2iqg0t3psahoje4k8r7r4pchbh05por38@4ax.com>. ..[color=blue]
> I missed the first part of this thread, but doesn't the following function do what is required?
> ...code...[/color]

You did miss the first part of this thread where I said:

"Recently, I have been trying to find ways to avoid relying on Access'
error handler mechanism in an effort to catch more errors before they
happen."

Although your code probably works very nicely, it doesn't avoid the
error handler mechanism.

James A. Fortune
Wayne Morgan
Guest
 
Posts: n/a
#10: Nov 13 '05

re: Determine if A: drive is empty


If anyone has written a dll, it is probably just a "wrapper" for the API
functions.

--
Wayne Morgan
Microsoft Access MVP


"James Fortune" <jafortun@oakland.edu> wrote in message
news:a6ed3ce7.0408011117.13904fdc@posting.google.c om...[color=blue]
> "Wayne Morgan" <comprev_gothroughthenewsgroup@hotmail.com> wrote in
> message news:<RKgOc.451$ID7.278@newssvr24.news.prodigy.com >...[color=green]
>> Yes, Microsoft has. See if this helps. It is for VB but should be able to
>> be
>> ported to Access with a couple of minor changes (namely the control array
>> on
>> the form).
>>
>> http://vbnet.mvps.org/index.html?cod...loppyready.htm
>>
>> --
>> Wayne Morgan
>> MS Access MVP[/color]
>
> It's nice to know that there's at least one way to use API functions
> to do it. Given the claim that MicroSoft's FileSystemObject is not
> totally reliable, I'll have to decide whether to create my own dll,
> use Randy Birch's solution, or cook up my own API solution in case I
> need to distribute it. Again, has anyone created their own dll that
> gets around the limitations of the FileSystemObject?
>
> James A. Fortune[/color]


Michael \(michka\) Kaplan [MS]
Guest
 
Posts: n/a
#11: Nov 13 '05

re: Determine if A: drive is empty


Try on Win9x when the drive is not ready (like the disk is not in or is
being taken out as you try to run the code?).

The code was not written on a whim, it was written to address a real
problem -- so why not let it solve the problem for you? :-)


--
MichKa [MS]
NLS Collation/Locale/Keyboard Development
Globalization Infrastructure and Font Technologies
Windows International Division

This posting is provided "AS IS" with
no warranties, and confers no rights.


"B. Austin" <baustin2NOSPAM@aol.com> wrote in message
news:be3rg0taoge9d2o0d8craigu0mis2hlaru@4ax.com...[color=blue]
> Mich -
>
> Thanks for the heads up.
>
> Always looking for opportunities to improve my code. What circumstances[/color]
would cause the OS to raise[color=blue]
> an error that would get past the 'FileExists' function? (I missed the[/color]
early parts of this thread.)[color=blue]
>
> TIA.
>
> - Brian
>
> On Sun, 1 Aug 2004 17:27:30 -0700, "Michael \(michka\) Kaplan [MS]"[/color]
<michkap@online.microsoft.com>[color=blue]
> wrote:
>[color=green]
> >I believe you may have problems with the OS putting up errors about there
> >being no disk -- the code that was posted works around that problem....[/color]
>
> (Remove NOSPAM to reply.)[/color]


Closed Thread