Split Database problem

S

ScrinnFenner

Hi all...using access 2k

I am trying to display images from a folder into a form by storing the image
names only in the database. I have followed the MS Knowledge Base Art 210100
and got it to work beautifully when the database was in one peice.
Having now split the database into front and back ends, and put onto network
drives, I have it snags, inasmuch as the database form does not update when
i add a new image to a record.
I have used frmImage as a sub form in the main form frmPersonnel, with both
txtImageName & imageID not visible.
Before the split, all files were in the same folder.

Could someone please help me out. For info, the locations of the different
files are as follwos:

Database Front End: H:\Database\Database.mdb

Database Back End: G:\Folder1\Folder2\Folder3\Database_be.mdb

Images are stored at: G:\Folder1\Folder2\Images\

Default Image: G:\Folder1\Folder2\Images\Crest.jpg

My coding is exactly as at Art 210100. I have tried both relative and full
path names but both fail.

Many thanks In advance

Matt
 
A

Adrian Jansen

Never had a problem specifically with a split database doing this. As long
as the image file has a fully qualified pathname to where it actually
exists, it should work fine. IE the text to get your image should be:

G:\Folder1\Folder2\Images\Crest.jpg

You are allowing enough time to get all those bytes across the network to
your form ?

--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
S

ScrinnFenner

Hi

Thanks for the reply.... 20 minutes????
Would you please do me a favour, and adapt the code as shown below to cater
for my file locations???

For full path names:

Function setImagePath()
Dim strImagePath As String
On Error Goto PictureNotAvailable
strImagePath = Me.txtImageName
Me.ImageFrame.Picture = strImagePath
Exit Function
PictureNotAvailable:
strImagePath = "G:\Folder1\Folder2\Images\Crest.jpg"
Me.ImageFrame.Picture = strImagePath
End Function

For relative path names:

Function setImagePath()
Dim strImagePath As String
Dim strMDBPath As String
Dim intSlashLoc As String
On Error Goto PictureNotAvailable
'Obtain the full path of the current database or Access Project
strMDBPath = CurrentProject.FullName
'Find the location of the last backslash
intSlashLoc = InStrRev(strMDBPath, "\", Len(strMDBPath))
'Trim off the database name, leaving the path
'and append the name of the image file
strImagePath = Left(strMDBPath, intSlashLoc) & _
Me.txtImageName
'Set ImageFrame to the path of the image file
Me.ImageFrame.Picture = strImagePath
Exit Function
PictureNotAvailable:
strImagePath = "crest.jpg"
Me.ImageFrame.Picture = strImagePath
End Function

Please please!! Theres a pint or two in it for you!!

Matty
 
A

Adrian Jansen

I presume you are storing the path to the images in a table - so that the
textbox txtImageName is bound to a table field ? And you have a mixture of
relative and absolute pathnames in the table ?

If so, I would do a once off run through the table with some code to set all
the pathnames to full paths, rather than have a mixture of relative paths
and full paths in the same field. An alternative, and maybe somewhat
better, is to store just the filename in one field, and the path without the
name in another. Then its easier to change just the paths if you ever
decide to move the images somewhere else. You can make some code to decide
what sort of path you have - basically look in the string for a disk name
like "C:\" and if that exists, the path is a full path, if not get the
current path as you have from the current project - by the way:

strPath = CurrentProject.path 'will return the path, without having to chop
up the full file name.

Then go through the table record by record, fixing the pathnames. Maybe at
the same time you might consider doing a DIR(pathname) to the image, and if
it doesnt exist, just scrap the record. Saves handling the case where the
image doesnt exist.


If on the other hand you have users typing in pathnames relative or full,
then you will have to do most of that on the fly. But you could help a lot
by giving your users a filepicker dialog box - and you can always get the
full path from that.

Post back if you need some more ideas.
--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 
S

ScrinnerFenner

Hi
Thanks for the reply.
I have been working on this. All txtImageName are full path names as
follows:

G:\Folder1\Folder2\Images\Image1.jpg
G:\Folder1\Folder2\Images\Image2.jpg
G:\Folder1\Folder2\Images\Image3.jpg etc
G:\Folder1\Folder2\Images\Crest.jpg as the default if
PictureNotAvailable
all as per art 210100.
I have checked the form and the table, and is as per 210100.

So I am using the following code:

Function setImagePath()
Dim strImagePath As String
On Error Goto PictureNotAvailable
strImagePath = Me.txtImageName
Me.ImageFrame.Picture = strImagePath
Exit Function
PictureNotAvailable:
strImagePath = "G:\Folder1\Folder2\Images\Crest.jpg"
Me.ImageFrame.Picture = strImagePath
End Function

All I get with each record is the crest.jpg. I get the same problem
with the database on my laptop, on two partitions (yes I have changed
the drive letters accordingly).!!!
Any thoughts? I beleive its in the code above not pointing to the
start properly, senses an error so points to the crest.jpg!!

Matt
 
A

Adrian Jansen

Cant see any obvious error. Try commenting out the on error function, and
step through the code line by line to see where the error actually occurs.
Also try a dir(strImagePath) to see if it returns a found filename:

Function setImagePath()
Dim strImagePath As String
dim junk as string
' On Error Goto PictureNotAvailable
strImagePath = Me.txtImageName
junk = dir(strImagePath)
debug.print junk
Me.ImageFrame.Picture = strImagePath
Exit Function
PictureNotAvailable:
strImagePath = "G:\Folder1\Folder2\Images\Crest.jpg"
Me.ImageFrame.Picture = strImagePath
End Function
--
Regards,

Adrian Jansen
J & K MicroSystems
Microcomputer solutions for industrial control
 

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