Home > Archive > MS Access database support > April 2006 > Dir Statement









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Dir Statement
deancarstens@yahoo.com

2006-04-06, 7:41 am

Hi,

Slight little problem again (hopefully the last one). The script below
should check whether my file path exists and then either load the data
or prompt the user to choose a path that exists. At the moment I'm
getting a bad file path error. Well, that is the idea. If I choose
C:\ (it should also load the ROAD DATABASE bit as I'm usually mapping
this over the network) it should check whether it exists and then load
the data from that path, but when I choose D:\ it should prompt me that
the path doesn't exist and then go back to the combo box so I can
choose again. So, using the Dir statement should give me a "" value if
I choose D:\. I'm getting the "", but it still doesn't want to
continue. Am I just using wrong syntax? PLEASE help.


Private Sub DriveCombo_Change()
Dim strCurrentFileLocati
on As String
Dim strComboValue As String
Dim strFixInterfacePath As String

strFixInterfacePath = "RDB\BIN\INTERFACE.mdb"

'First set the drive letter to the value in the combo box
DriveCombo.SetFocus
strComboValue = DriveCombo.Text

If strComboValue = "C:\" Then
strDriveSelect = "C:\ROAD DATABASE\"
Else
strDriveSelect = strComboValue
End If

Debug.Print "This is where the interface is currently located: " &
strDriveSelect & strFixInterfacePath
Debug.Print Dir(strDriveSelect & strFixInterfacePath)



If Dir(strDriveSelect & strFixInterfacePath)
= "" Then
MsgBox "You do not seem to have the ROAD DATABASE set up on: " _
& strDriveSelect & " " & _
vbNewLine & vbNewLine & _
"Please change the drive letter in the next dialog.", vbCritical,
"Change Your Drive"
Else
'Check what the value for the combobox is and set the public
variable accordingly
If DriveCombo.Text = "C:\" Then
strComboValue = "C:\ROAD DATABASE\"
strDriveSelect = strComboValue
'Tell the user drive will load
MsgBox ("Your application will now point to: " & vbNewLine
& vbNewLine _
& strComboValue & "RDB\...")
'Set the text on the form
Label12.Caption = "If your data connection is not mapped as
the " _
& "C:\... drive, then please select the appropriate drive "
_
& "letter from the list below:"
Else
strComboValue = DriveCombo.Text
strDriveSelect = strComboValue
MsgBox ("Your application will now point to: " & vbNewLine
& vbNewLine _
& strComboValue & "RDB\...")
Label12.Caption = "If your data connection is not mapped as
the " _
& strDriveSelect & "... drive, then please select the
appropriate drive " _
& "letter from the list below: "
End If
End If

End Sub



Dean Carstens

Scott Wilson
DFID Support to Feeder Roads
Ghana

Larry Linson

2006-04-06, 8:29 pm

First, the AfterUpdate event is a better place for your code, because Change
fires after every keystroke. That may or may not be acceptable here, but it
usually is not what you want to be doing.

Second, visit the FAQ site for this newsgroup,
http://www.mvps.org/access/api/api0001.htm and consider using the Windows
Common Dialog, instead of what you are doing. I find it simple and
straightforward, and you don't have to distribute any ActiveX controls along
with your application.

Larry Linson
Microsoft Access MVP



<deancarstens@yahoo.com> wrote in message
news:1144314507.237630.264870@v46g2000cwv.googlegroups.com...
> Hi,
>
> Slight little problem again (hopefully the last one). The script below
> should check whether my file path exists and then either load the data
> or prompt the user to choose a path that exists. At the moment I'm
> getting a bad file path error. Well, that is the idea. If I choose
> C:\ (it should also load the ROAD DATABASE bit as I'm usually mapping
> this over the network) it should check whether it exists and then load
> the data from that path, but when I choose D:\ it should prompt me that
> the path doesn't exist and then go back to the combo box so I can
> choose again. So, using the Dir statement should give me a "" value if
> I choose D:\. I'm getting the "", but it still doesn't want to
> continue. Am I just using wrong syntax? PLEASE help.
>
>
> Private Sub DriveCombo_Change()
> Dim strCurrentFileLocati
on As String
> Dim strComboValue As String
> Dim strFixInterfacePath As String
>
> strFixInterfacePath = "RDB\BIN\INTERFACE.mdb"
>
> 'First set the drive letter to the value in the combo box
> DriveCombo.SetFocus
> strComboValue = DriveCombo.Text
>
> If strComboValue = "C:\" Then
> strDriveSelect = "C:\ROAD DATABASE\"
> Else
> strDriveSelect = strComboValue
> End If
>
> Debug.Print "This is where the interface is currently located: " &
> strDriveSelect & strFixInterfacePath
> Debug.Print Dir(strDriveSelect & strFixInterfacePath)

>
>
> If Dir(strDriveSelect & strFixInterfacePath)
= "" Then
> MsgBox "You do not seem to have the ROAD DATABASE set up on: " _
> & strDriveSelect & " " & _
> vbNewLine & vbNewLine & _
> "Please change the drive letter in the next dialog.", vbCritical,
> "Change Your Drive"
> Else
> 'Check what the value for the combobox is and set the public
> variable accordingly
> If DriveCombo.Text = "C:\" Then
> strComboValue = "C:\ROAD DATABASE\"
> strDriveSelect = strComboValue
> 'Tell the user drive will load
> MsgBox ("Your application will now point to: " & vbNewLine
> & vbNewLine _
> & strComboValue & "RDB\...")
> 'Set the text on the form
> Label12.Caption = "If your data connection is not mapped as
> the " _
> & "C:\... drive, then please select the appropriate drive "
> _
> & "letter from the list below:"
> Else
> strComboValue = DriveCombo.Text
> strDriveSelect = strComboValue
> MsgBox ("Your application will now point to: " & vbNewLine
> & vbNewLine _
> & strComboValue & "RDB\...")
> Label12.Caption = "If your data connection is not mapped as
> the " _
> & strDriveSelect & "... drive, then please select the
> appropriate drive " _
> & "letter from the list below: "
> End If
> End If
>
> End Sub
>
>
>
> Dean Carstens
>
> Scott Wilson
> DFID Support to Feeder Roads
> Ghana
>



deancarstens@yahoo.com

2006-04-07, 7:42 am

Thanks Larry,

Like a charm! Thanks for the advice.

Dean

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com