views:

47

answers:

4

Hi developing an application in Access. The access file will be located on a db however when users need to use it, I want them to copy it on there desktop. If they do run it off the G:\ drive (our networked folder), it should give them a message.

So are there Win API that will help me solve this? I am going to put this code in the Form_Load event of a form.

A: 

I think there's a call that will list the (physically) attached drives on a machine, you could call that and compare the drive specifier on the path the user gave against the list.

TMN
any idea on what it might be called
masfenix
+1  A: 

You can use the FileSystemObject DriveType property

http://msdn.microsoft.com/en-us/library/ea5ht6ax(VS.85).aspx

If you need the desktop folder, you might like to look at:

CreateObject("WScript.Shell").SpecialFolders("Desktop")
Remou
A: 

If you want to prevent the users opening your database from the G:\ drive, you can do a simple check with code like this in your startup form:

Dim strMsg As String
If CurrentProject.Path Like "G:*" Then
    strMsg = "Please copy this database file to your " & _
        "local disk and open the copy instead of this one."
    MsgBox strMsg
    Application.Quit
End If

If you also want to prevent them opening the database from a different drive letter mapping or a UNC path, you could add a file such as NotFromHere.txt to the folder where your database file is stored.

Dim strMsg As String
Dim strFilePath
strFilePath = CurrentProject.Path & Chr(92) & "NotFromHere.txt"
If Len(Dir(strFilePath)) > 0 Then
    strMsg = "Please copy this database file to your " & _
        "local disk and open the copy instead of this one."
    MsgBox strMsg
    Application.Quit
End If
HansUp
Thankyou for an alternate solution. I will go with the second way because the drive letter could change so I dont want to hard code it.
masfenix
The requirements changed for this and we determined its not a viable solution. We are gonna go a whole different route. thanks though
masfenix
+1  A: 

You might want to check out the excellent access auto FE updater as an automated way of copying down updates etc

http://autofeupdater.com/

I rolled my own very similar system before I found this one and it does make updating the FE so much easier

Kevin Ross