I use the following code (got from this forum somewhere a while back) to open a "browse" box which enables my user to link a file to the database. it works from an "add" button which then places the string for the file into a field and turns it into a hyperlink using another bit of code.
I now need to change it so that it will only allow my users to choose a file from a specific folder. This is because we have some uninformed users who attach a file which is on their PC desktop and then wonder why no one else can open it!
Can anyone help please?
Private Sub add1_Click()
On Error GoTo add1_Err
Dim strFilter As String
Dim lngFlags As Long
Dim varFileName As Variant
strFilter = "All Files (*.*)" & vbNullChar & "*.*" _
& vbNullChar & "All Files (*.*)" & vbNullChar & "*.*"
lngFlags = tscFNPathMustExist Or tscFNFileMustExist _
Or tscFNHideReadOnly
varFileName = tsGetFileFromUser( _
fOpenFile:=True, _
strFilter:=strFilter, _
rlngflags:=lngFlags, _
strDialogTitle:="Please choose a file...")
If IsNull(varFileName) Then
Else
Me![Attach drawing:] = varFileName
End If
add1_End:
On Error GoTo 0
Exit Sub
add1_Err:
Beep
MsgBox Err.Description, , "Error: " & Err.Number _
& " in file"
Resume add1_End
End Sub
I now need to change it so that it will only allow my users to choose a file from a specific folder. This is because we have some uninformed users who attach a file which is on their PC desktop and then wonder why no one else can open it!
Can anyone help please?
Private Sub add1_Click()
On Error GoTo add1_Err
Dim strFilter As String
Dim lngFlags As Long
Dim varFileName As Variant
strFilter = "All Files (*.*)" & vbNullChar & "*.*" _
& vbNullChar & "All Files (*.*)" & vbNullChar & "*.*"
lngFlags = tscFNPathMustExist Or tscFNFileMustExist _
Or tscFNHideReadOnly
varFileName = tsGetFileFromUser( _
fOpenFile:=True, _
strFilter:=strFilter, _
rlngflags:=lngFlags, _
strDialogTitle:="Please choose a file...")
If IsNull(varFileName) Then
Else
Me![Attach drawing:] = varFileName
End If
add1_End:
On Error GoTo 0
Exit Sub
add1_Err:
Beep
MsgBox Err.Description, , "Error: " & Err.Number _
& " in file"
Resume add1_End
End Sub