Link to home
Start Free TrialLog in
Avatar of LenaWood
LenaWood

asked on

Using CurrentProject.path

I have a database that I use to make Accountability Cards for evacuation purposes.  These cards have the photos of the employees on them.  I am in the process of incorporating the Accountability Cards into our Employee Database...seems silly to have two different databases to hold information about our employees and my coworkers think it would be a great idea to be able to pull up someones record in the Employee Database and see their picture (Will have to figure out how to block mine haha).

I saw that you can use CurrentProject.path to get the path of the database.  If I stored the pictures in the same folder as the database (in a folder called Pictures), could I use CurrentProject.path to help me show the pictures of the employees?  One of the reasons I want to be able to do this is if for some reason they need to move our folder on the network the drive may change names (from rdc1 to HarryTheHamster) and I don't want to have to go in and find all the places in my code where I use rdc1 (not that there are very many, but if I win the lottery I won't be here to fix their broken picture links).

Is using CurrentProject.path for this possible (and not really complicated)?

Thanks!
Lena
ASKER CERTIFIED SOLUTION
Avatar of rockiroads
rockiroads
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LenaWood
LenaWood

ASKER

Where this database resides is on a network drive that is backed up every night (at least the files that changed during the day) and completely backed up once a week.

The users of the database will have a front end stored on their desktops and won't have the drive actually mapped to their computers - I know that doesn't solve issues with people messing with the pictures, but most people out here don't know how to map a drive to be able to mess with the pictures.

So I could store something like Photos\LenaWood.jpg in a field in my table, and when I tell the picture box on my form (OLE object?) where to look, I could say Currentproject.path & "\" & me.pictureplace, right?  Of course my next question will be how to store just the Photos\LenaWood.jpg, but I will figure that out down the road (if this is doable).

Lena
Yes thats okay then

Use a image control to load your pictures. Very easy

just do

imgCtrl.Picture = currentproject.path & sImageFilePath


Nothing wrong with what u do, but if I did this, I would still store a path in a table and make use of that.
If I store the path in the table and the database gets moved to a different sever then all my paths are wrong...no?  How would I automatically fix the path names?  I need to do something that won't need to be fixed by ME if IT chooses to switch the servers....I plan on winning the lottery and going on a very very long vacation :-)

Lena
yes, thats true. Thats why its a config table, u simply change the path in that table

Your approach is easier in terms of maintenance.

I guess photo's can be considered data and therefore being placed with a backend database is fine.

I would recommend you make the photo's directory read only for all users, except admin

I see u still remember good old Harry the Hampster!
So the path (the first part of it anyway) is stored in a single field in a table...yes?  So how do I link a single photo to each person.  OK...maybe today isn't a good day for questions...I am catching my daughters "blonde" attitude.

Lena
Is this a FE split application?
Or does the "FE" actually sit on the server - shared by all?

I'm just wondering of how much use currentproject.path will be - you don't want images stored on local pc's surely. :-S
It is split and each person has their own personal front end.  The BE is stored on the network drive.

As it should be - cool.
And you'll want to store these images with the data files on the server yeah.

But that means currentproject.path won't be of much help in that respect.
You'll have to examine the table link yeah?
Yes, the photos will be stored in a subfolder in the folder with the mdb files.
Yes...I didn't even think about the table link...well phoey!
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ok ... so how do you get the name of the picture file into your database ...

getb the common file dialog api code if you do not already have it ... (http://www.mvps.org/access/api/api0001.htm)

and add a builder button on your employee administration form to navigate to your picture folder and select the appropriate picture.

Steve
Leigh,

The code you gave does show the path to the backend and just the path to the folder itself.  I am sure this will be useful when I figure out what I am going to do with this.

Steve,

I have something similar to the link that you gave me - I was going to use it for making my mom a database for her Tole Books.  She wanted to be able to show the cover of the book in the database (easier to show the insurance what books she had that way).  Anyway, the code that I am using shows me the complete path to the picture.

CODE:

Private Sub GetPic_Click()

Dim strFilter As String
Dim strInputFileName As String

'create the filter that displays in the "File Type" drop down at the bottom of the File Dialog box
'I made it jpg based on earlier discussions ... you can make it whatever you want.

strFilter = ahtAddFilterItem(strFilter, "Picture Files (*.JPG)", "*.JPG")
strFilter = ahtAddFilterItem(strFilter, "All Files (*.*)", "*.*")
strFilter = ahtAddFilterItem(strFilter, "Picture Files (*.BMP)", "*.BMP")
strFilter = ahtAddFilterItem(strFilter, "Picture Files (*.gif)", "*.GIF")

'open the file dialog box and return path to the selected file
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select a picture file...", _
Flags:=ahtOFN_HIDEREADONLY)

'make sure a file was selected
If Len(strInputFileName) > 0 Then
'write the value to the textbox that is bound to your PicPath field
Me.PicPath.Value = strInputFileName

'display the selected picture
Me.imgPic.Picture = Me.PicPath.Value
End If

End Sub

Gives me:  N:\ToleBook\ToleBooks\Gourd Fun.gif

My question I guess is how would I get it to just show me Gourd Fun.gif?

I am not sure how much I will understand today...spent all day out in the heat yesterday (at an estate auction) and didn't get home until 1am this morning....I am functioning on luck this morning.

Lena
I just realized that no matter how much I am trying to make it so that if something gets moved it won't help alot.  I have a Auto-Updater in use (I update the front end of the database and when each person starts their own database front end it checks to see if they have the newest version) and you have to point it to the front end (Master copy) on the server...if it gets moved the database just won't startup.

Oh well....I still want to make this other part work.  The more I have set up to fix itself, the less someone else will have to figure out how to do :-)

Lena
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you, I will try this out and let you know how it goes.

Lena
OK...silly question.  Should the config table actually be in the backend?  Using my tired logic, I would say no...but then again I am tired.

Lena
No is right :-)

(Although - that could depend on the config tables you have - I usually have a local one and a systemwide one).
Hey Lena, I see your going for the config table approach

Good choice

I guess Leigh is better at explaining that approach than I was!

No Rocki - you and Harry the Hamster are quite the team :-)  I understood what you thought I should do, just wasn't 100% sure I understood how to go about it is all.  My head just hasn't been in the game lately - but don't give up on me.

Rocki uses the gentle approach....Leigh just smacks me over the head...each approach works depending on the day!

Honestly, I couldn't and wouldn't be here at my job doing what I do today without the 3 of you (Rocki, Leigh and Harry) among many others.

THANKS!
Lena
Thanks!

I thought my kids were bad, damn, Im watching this program called Driving Mum and Dad

3 yr olds swearing and hitting their parents, damn
Makes you wonder why the parents didn't put a stop to it the first time it happened.  My kids would NEVER do anything like that...they may want too, but don't.  (I am glad they don't, as they are both able to kick my butt now - getting old sucks!).

Thanks again Rocki....you will be awarded as you derserve, not only with EE points, but also with the gratitude of many.

Lena
For your picture path I would put that in a BE config table so you can cghnage it on the fly without distributing a new version of the FE. That is why my "PicPath" function stores the results in a var, you only have to make a hit to the BE one time per session.

Steve
Thank you Steve for the information.  My goal for today is to make this work.  I shall return with more questions if I have them.

Lena
Thank you Rocki, Steve and Leigh....you have all helped me learn alot with this question.

Until the next question.....:-)

Lena