Hi to everyone,
I am reading this forum for a long time now and it helped me a lot in Access database developing. Here is my problem. I developed a database for tracking of patients in one orthopedic house. That includes also putting the pictures. So, I found on this forum a code for opening a dialog for browsing for files. Pictures are in fact linked and only the path of picture is actually written in database. But, now the problem is that it is network enviroment with server and everything which goes with that.
So, I would like to modify this browse dialog when someone wants to insert new picture on way that when he picks the picture then that picture should be first copied to one specified folder which is on network drive and after that this new path for the picture should be automaticaly written in my db so path of the picture location would be always from network drive and not from local machine. On that way everyone would be able to see all pictures all the time (all pictures would be copied to one specified folder).
Here is function I am using for opening browse dialog:
I have to mention that I am realy not good in coding so detailed explanation would be very good for me. On that way I will learn something more...
Thank you in advance,
gile2004
I am reading this forum for a long time now and it helped me a lot in Access database developing. Here is my problem. I developed a database for tracking of patients in one orthopedic house. That includes also putting the pictures. So, I found on this forum a code for opening a dialog for browsing for files. Pictures are in fact linked and only the path of picture is actually written in database. But, now the problem is that it is network enviroment with server and everything which goes with that.
So, I would like to modify this browse dialog when someone wants to insert new picture on way that when he picks the picture then that picture should be first copied to one specified folder which is on network drive and after that this new path for the picture should be automaticaly written in my db so path of the picture location would be always from network drive and not from local machine. On that way everyone would be able to see all pictures all the time (all pictures would be copied to one specified folder).
Here is function I am using for opening browse dialog:
Code:
Option Compare Database
Option Explicit
Type OPENFILENAME
lStructSize As Long
hwndOwner As Long
hInstance As Long
lpstrFilter As String
lpstrCustomFilter As String
nMaxCustFilter As Long
nFilterIndex As Long
lpstrFile As String
nMaxFile As Long
lpstrFileTitle As String
nMaxFileTitle As Long
lpstrInitialDir As String
lpstrTitle As String
flags As Long
nFileOffset As Integer
nFileExtension As Integer
lpstrDefExt As String
lCustData As Long
lpfnHook As Long
lpTemplateName As String
End Type
Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (OFN As OPENFILENAME) As Boolean
Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias _
"GetSaveFileNameA" (OFN As OPENFILENAME) As Boolean
Private Const ALLFILES = "All files"
Function MakeFilterString(ParamArray varFilt() As Variant) As String
Dim strFilter As String
Dim intRes As Integer
Dim intNum As Integer
intNum = UBound(varFilt)
If (intNum <> -1) Then
For intRes = 0 To intNum
strFilter = strFilter & varFilt(intRes) & vbNullChar
Next
If intNum Mod 2 = 0 Then
strFilter = strFilter & "*.*" & vbNullChar
End If
strFilter = strFilter & vbNullChar
End If
MakeFilterString = strFilter
End Function
Private Sub InitOFN(OFN As OPENFILENAME)
With OFN
.hwndOwner = hWndAccessApp
.hInstance = 0
.lpstrCustomFilter = vbNullString
.nMaxCustFilter = 0
.lpfnHook = 0
.lpTemplateName = 0
.lCustData = 0
.nMaxFile = 511
.lpstrFileTitle = String(512, vbNullChar)
.nMaxFileTitle = 511
.lStructSize = Len(OFN)
If .lpstrFilter = "" Then
.lpstrFilter = MakeFilterString(ALLFILES)
End If
.lpstrFile = .lpstrFile & String(512 - Len(.lpstrFile), vbNullChar)
End With
End Sub
Function OpenDialog(OFN As OPENFILENAME) As Boolean
Dim intRes As Integer
InitOFN OFN
intRes = GetOpenFileName(OFN)
If intRes Then
With OFN
.lpstrFile = Left$(.lpstrFile, InStr(.lpstrFile, vbNullChar) - 1)
End With
End If
OpenDialog = intRes
End Function
I have to mention that I am realy not good in coding so detailed explanation would be very good for me. On that way I will learn something more...
Thank you in advance,
gile2004