Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: Checking to see if the A: Drive has a disk loaded


Message #1 by "Byron O'Neal" <oneal@p...> on Tue, 1 May 2001 18:24:23
I want to design a form with a button that when depressed will send a Text 

file to the A: Drive.  Is there a way of trapping an error if there is no 

disk in the Drive?

TIA



Byron
Message #2 by "Carol Mandra" <carol_mandra@r...> on Wed, 2 May 2001 22:40:50
> I want to design a form with a button that when depressed will send a 

Text > file to the A: Drive.  Is there a way of trapping an error if there 

is no > disk in the Drive?

> TIA

> 

Hi, use visual basic behind the button, make it the first lines:  Carol :-)



Sub dira()

    Dim myfile As String

    myfile = Dir("C:\WINDOWS\*.INI")

    If myfile = "" Then

        MsgBox "Put a disk in the a Drive!"

        end sub

    End If

    

End Sub



Message #3 by "John Ruff" <papparuff@c...> on Wed, 2 May 2001 17:12:51 -0700
Byron,



Try this.  I have a form with a button called cmdSaveToA.  On the Click

event, I have the following code that will solve your problem.



Private Sub cmdSaveToA_Click()



    On Error GoTo cmdSaveToA_Click_ERR



    Dim strSourceFile

    Dim strDestinationFile

    Dim strMsg As String



    ' Determine if File Exists

    If FileLen("C:\Documents and Settings\Administrator.PAPPARUFF\My

Documents\db1.mdb") > 0 Then

        ' Source File Name

        strSourceFile = "C:\Documents and

Settings\Administrator.PAPPARUFF\My Documents\db1.mdb"   ' Define source

file name.

        ' Target File Name

        strDestinationFile = "a:\db1.mdb"

        ' Copy File

        FileCopy strSourceFile, strDestinationFile

    Else

        strMsg = "The file " & vbCrLf & strSourceFile & vbCrLf & _

                    " could not be found.  The copy is cancelled."

        MsgBox strMsg

    End If



cmdSaveToA_Click_EXIT:



    Exit Sub



cmdSaveToA_Click_ERR:



    If Err = 71 Then    ' Disk is not Ready (No disk in the A: Drive)

        strMsg = "Please insert a Floppy Disk into the A Drive" & vbCrLf & _

                    "Then Press OK"

        ' Resume the copy if the person presses the OK button

        If MsgBox(strMsg, vbDefaultButton1 + vbOKCancel + vbOKOnly) = vbOK

Then

            Resume

        End If

    Else

        MsgBox Err.Number & "-" & Error$

    End If

    Resume cmdSaveToA_Click_EXIT



End Sub



John Ruff - The Eternal Optimist :)

 -----Original Message-----

From: 	Byron O'Neal [mailto:oneal@p...]

Sent:	Tuesday, May 01, 2001 6:24 PM

To:	Access

Subject:	[access] Checking to see if the A: Drive has a disk loaded



I want to design a form with a button that when depressed will send a Text

file to the A: Drive.  Is there a way of trapping an error if there is no

disk in the Drive?

TIA



Byron








Message #4 by "Wade Weal" <wadeweal@h...> on Mon, 7 May 2001 14:34:41 -0400
It can be done with Windows API programming, but sometimes that can be

overkill and this seems like one of those times.  I wrote a procedure that

saves an Excel file to the A:\ drive and trapped the error:



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

On Error GoTo Err_cmdExcel_Click



Dim strExclName As String



 'I'm pulling in the file name from a text box on a form

strExclName = "a:\" & Me!txtFileName & ".xls"



If IsNull(Me!txtFileName) Then

    Beep

    MsgBox "Please select a division first.", vbOKOnly

Else

    DoCmd.OutputTo acReport, "rptFullTrustee", "MicrosoftExcel(*.xls)",

"a:\" & Me!txtFileName & ".xls", True, ""

End If



exit_cmdexcel_click:

    Exit Sub



Err_cmdExcel_Click:

    Beep

    MsgBox "Is there a floppy in the A drive?", vbOKOnly

    Resume exit_cmdexcel_click:



----- Original Message -----

From: "Byron O'Neal" <oneal@p...>

To: "Access" <access@p...>

Sent: Tuesday, May 01, 2001 6:24 PM

Subject: [access] Checking to see if the A: Drive has a disk loaded





> I want to design a form with a button that when depressed will send a Text

> file to the A: Drive.  Is there a way of trapping an error if there is no

> disk in the Drive?

> TIA

>

> Byron

>

  Return to Index