Form coding behaves differently when db is on the network

S

Steve D

Here is the code:

Private Sub cmdEditImage_Click()
Dim strPic As String
Dim picpath As String

picpath = "\\Misuv01\user\Access Database Import Textiles"
strPic = """" & picpath & "\Photos\" & Me.txtPhoto & """"
End Sub
--
Private Sub show_image()
Dim picpath As String

picpath = "\\Misuv01\user\Access Database Import Textiles"

If IsNull(txtPhoto) = True Or Trim(txtPhoto) = "" Then
imgPhoto.Picture = ""
Else
Set FSO = CreateObject("Scripting.FileSystemObject")
If FSO.FileExists(picpath & "\Photos\" & txtPhoto) = True Then
imgPhoto.Picture = picpath & "\Photos\" & txtPhoto
Else
MsgBox "Cannot find the image file " & txtPhoto, vbCritical,
"Error - Missing File"
End If
End If
End Sub
--
Private Sub cmdPicture_Click()
Dim lngFormName As Long, lngAppInstance As Long
Dim strInitDir As String, strFileFilter As String
Dim lngResult As Long
Dim picpath As String

Dim cdlg As New CommonDialogAPI

lngFormName = Me.hwnd
lngAppInstance = Application.hWndAccessApp
picpath = "\\Misuv01\user\Access Database Import Textiles"
strInitDir = picpath & "\Photos\"
strFileFilter = "JPEG Image Files (*.jpg)" & Chr(0) & "*.jpg" & Chr(0)

lngResult = cdlg.OpenFileDialog(lngFormName, lngAppInstance, strInitDir,
strFileFilter)

If cdlg.GetStatus = True Then
txtPhoto = cdlg.GetTitle
Me.Repaint

If Left$(cdlg.GetName, Len(cdlg.GetName) - Len(cdlg.GetTitle)) _
<> picpath & "\Photos\" Then CopyFile cdlg.GetName, picpath & "\Photos\"
& cdlg.GetTitle

show_image
Else
MsgBox "No file selected."
End If
End Sub
--
The context here is that users (while on the main form) have the option to
insert or change a photo. The file name of the photo is displayed in a text
box beneath the photo and the path to the photo is stored in the db (rather
than the photo itself). Also, the folder called 'Photos' and the .mdb file
must reside in the same folder (with the db alongside the Photos folder.
While testing this code I had a seperate folder on my desktop (containing the
db and the Photos folder). The code worked perfectly! Since then I have
migrated this project to the network at my office. What is strange is that as
I click the 'Insert/Edit' button to search the directory for the photos and
select a photo for a new record - the file name will be displayed in the text
box BUT the image does not appear. If I move off the current record and then
return to that previous record the link to the photo fires and the photo will
load. Looking for the correction / fix.

Thanks ahead,
Steve D

Thanks,
Steve D
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top