473,473 Members | 2,032 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Determine if A: drive is empty

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
....
Nov 13 '05 #1
10 1952
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" <li*****@schoollink.net> wrote in message
news:84********************************@4ax.com...
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
...

Nov 13 '05 #2
Chuck <li*****@schoollink.net> wrote in message news:<84********************************@4ax.com>. ..
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
...


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
Nov 13 '05 #3
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" <ja******@oakland.edu> wrote in message
news:a6**************************@posting.google.c om...
Chuck <li*****@schoollink.net> wrote in message news:<84********************************@4ax.com>. ..
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
...


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

Nov 13 '05 #4
"Wayne Morgan" <co***************************@hotmail.com> wrote in message news:<RK***************@newssvr24.news.prodigy.com >...
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


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
Nov 13 '05 #5
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, ja******@oakland.edu (James Fortune) wrote:
"Wayne Morgan" <co***************************@hotmail.com> wrote in message news:<RK***************@newssvr24.news.prodigy.com >...
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


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


(Remove NOSPAM to reply.)
Nov 13 '05 #6
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" <ba************@aol.com> wrote in message
news:e2********************************@4ax.com...
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, ja******@oakland.edu (James Fortune) wrote:
"Wayne Morgan" <co***************************@hotmail.com> wrote in message news:<RK***************@newssvr24.news.prodigy.com >...
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


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


(Remove NOSPAM to reply.)

Nov 13 '05 #7
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]" <mi*****@online.microsoft.com>
wrote:
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....


(Remove NOSPAM to reply.)
Nov 13 '05 #8
B. Austin <ba************@aol.com> wrote in message news:<e2********************************@4ax.com>. ..
I missed the first part of this thread, but doesn't the following function do what is required?
...code...


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
Nov 13 '05 #9
If anyone has written a dll, it is probably just a "wrapper" for the API
functions.

--
Wayne Morgan
Microsoft Access MVP
"James Fortune" <ja******@oakland.edu> wrote in message
news:a6**************************@posting.google.c om...
"Wayne Morgan" <co***************************@hotmail.com> wrote in
message news:<RK***************@newssvr24.news.prodigy.com >...
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


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

Nov 13 '05 #10
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" <ba************@aol.com> wrote in message
news:be********************************@4ax.com...
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]" <mi*****@online.microsoft.com> wrote:
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....


(Remove NOSPAM to reply.)

Nov 13 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: mh | last post by:
Hi Folks- I'm trying to do a simple emulation of unix "locate" functionality in python for windows. Problem is I don't want to crawl/index optical drives. Do any of the windows people out...
3
by: KSC | last post by:
Hello, Is there a way to programmatically determine if a directory is shared and if so, what the sharename is? It seems a simple question, but I have been searching and not found the...
2
by: robert d via AccessMonster.com | last post by:
I need to determine for sure if a particular fie is on the user's local PC or on the server. I have the complete path of the file, let's call it FullFilePath How can I unequivocally determine...
9
by: paktsardines | last post by:
Dear all, As of yesterday I have this function: char ** lines = read_file("filename.txt"); Now, I want to print the contents of lines. A first attempt: int i=0;
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.