S
Seth
I am using a module that calls directly into comdlg32.dll to allow user to
select a file name using the Windows Common Dialog.
I downloaded an example by ghudson from:
http://www.access-programmers.co.uk/forums/showthread.php?t=75790
In ghudson’s code below he sets focus to a hidden text box on the form
(tbHidden). tbHidden is an unbound text box with a height and width of
0.025cm which is placed in the top left-hand corner of form
fFindOpenImportFile.
Why does he set focus to tbHidden?
Cheers,
Seth
ghudson’s code in form fFindOpenImportFile:
---------------------------------------------------
Private Sub bBrowse_Click()
On Error GoTo Err_bBrowse_Click
Dim strFilter As String
Dim lngFlags As Long
Dim varFileName As Variant
Me.tbHidden.SetFocus ‘****** What is this for?
' strFilter = "Access (*.mdb)" & vbNullChar & "*.mdb" _
' & vbNullChar & "All Files (*.*)" & vbNullChar & "*.*"
' strFilter = "Access Files (*.mdb)" & vbNullChar & "*.mdb*"
strFilter = "All Files (*.*)" & vbNullChar & "*.*"
lngFlags = tscFNPathMustExist Or tscFNFileMustExist Or tscFNHideReadOnly
varFileName = tsGetFileFromUser( _
fOpenFile:=True, _
strFilter:=strFilter, _
rlngflags:=lngFlags, _
strDialogTitle:="Find File (Select The File And Click The Open Button)")
If IsNull(varFileName) Or varFileName = "" Then
Debug.Print "User pressed 'Cancel'."
Beep
MsgBox "File selection was canceled.", vbInformation
Exit Sub
Else
'Debug.Print varFileName
tbFile = varFileName
End If
Call ParseFileName
Exit_bBrowse_Click:
Exit Sub
Err_bBrowse_Click:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_bBrowse_Click
End Sub
-----------------------------------------------------------
select a file name using the Windows Common Dialog.
I downloaded an example by ghudson from:
http://www.access-programmers.co.uk/forums/showthread.php?t=75790
In ghudson’s code below he sets focus to a hidden text box on the form
(tbHidden). tbHidden is an unbound text box with a height and width of
0.025cm which is placed in the top left-hand corner of form
fFindOpenImportFile.
Why does he set focus to tbHidden?
Cheers,
Seth
ghudson’s code in form fFindOpenImportFile:
---------------------------------------------------
Private Sub bBrowse_Click()
On Error GoTo Err_bBrowse_Click
Dim strFilter As String
Dim lngFlags As Long
Dim varFileName As Variant
Me.tbHidden.SetFocus ‘****** What is this for?
' strFilter = "Access (*.mdb)" & vbNullChar & "*.mdb" _
' & vbNullChar & "All Files (*.*)" & vbNullChar & "*.*"
' strFilter = "Access Files (*.mdb)" & vbNullChar & "*.mdb*"
strFilter = "All Files (*.*)" & vbNullChar & "*.*"
lngFlags = tscFNPathMustExist Or tscFNFileMustExist Or tscFNHideReadOnly
varFileName = tsGetFileFromUser( _
fOpenFile:=True, _
strFilter:=strFilter, _
rlngflags:=lngFlags, _
strDialogTitle:="Find File (Select The File And Click The Open Button)")
If IsNull(varFileName) Or varFileName = "" Then
Debug.Print "User pressed 'Cancel'."
Beep
MsgBox "File selection was canceled.", vbInformation
Exit Sub
Else
'Debug.Print varFileName
tbFile = varFileName
End If
Call ParseFileName
Exit_bBrowse_Click:
Exit Sub
Err_bBrowse_Click:
MsgBox Err.Number & " - " & Err.Description
Resume Exit_bBrowse_Click
End Sub
-----------------------------------------------------------