This script below is having problems with allow the selestion of *.mdb files off the network. Can anyone see the problem with the code?
[code]
Function ImportFile(strform As Form) As Boolean
Dim OpenFile As OPENFILENAME
Dim lReturn As Long
Dim sFilter As String
Dim ChosenFileName As String
ImportFile = True
OpenFile.lStructSize = Len(OpenFile)
OpenFile.hwndOwner = strform.Hwnd
sFilter = "Microsoft Access (*.mdb)" & Chr(0) & "*.mdb" & Chr(0) & _
"All Files (*.*)" & Chr(0) & "*.*" & Chr(0)
' "Text (*.TXT)" & Chr(0) & "*.TXT" & Chr(0) &
OpenFile.lpstrFilter = sFilter
OpenFile.nFilterIndex = 1
OpenFile.lpstrFile = String(257, 0)
OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
OpenFile.lpstrFileTitle = OpenFile.lpstrFile
OpenFile.nMaxFileTitle = OpenFile.nMaxFile
OpenFile.lpstrInitialDir = "C:\"
OpenFile.lpstrTitle = "Select an Access Database"
OpenFile.flags = 0
lReturn = GetOpenFileName(OpenFile)
ChosenFileName = Left(OpenFile.lpstrFile, InStr(OpenFile.lpstrFile, ".") + 3)
If lReturn = 0 Then
MsgBox "A file was not selected!", vbInformation, "Select a File"
ImportFile = False
ElseIf LCase(Right(ChosenFileName, 4)) = ".mdb" Then
LinkTables (ChosenFileName)
Else
MsgBox "File must be an Access Database (*.mdb)!", vbOKOnly, "Error"
ImportFile = False
End If
End Function