Tom Knowlton
asked on
Weird one - Application.CurrentProject.Path not returning correct path?
I have an MS Access 2000 application which uses a call to
Application.CurrentProject .Path
When I run the MS Access application on my machine it works just fine and returns the correct path.
However, when I deploy the MDB to another machine.....somehow.....I don't know how......it is retaining the application path from MY machine....instead of using the new one on the current machine!!!!
How could the path get embedded inside my application like that?
Application.CurrentProject
When I run the MS Access application on my machine it works just fine and returns the correct path.
However, when I deploy the MDB to another machine.....somehow.....I don't know how......it is retaining the application path from MY machine....instead of using the new one on the current machine!!!!
How could the path get embedded inside my application like that?
ASKER
I've run compact and repair and compiled **just before** distributing the app......same problem.
ASKER
To see the problem for yourself:
http://www.robotzgame.com/inven_updates/dload.htm
the link at the very top of the page is the one you want.
http://www.robotzgame.com/inven_updates/dload.htm
the link at the very top of the page is the one you want.
just for testing .... does CurrentDb.Name tell you the correct location?
Steve
Steve
ASKER
>>>ust for testing .... does CurrentDb.Name tell you the correct location?
Let me check that....it'll take me a few minutes...
Let me check that....it'll take me a few minutes...
hey tom ... if you have picture links it will always try to find them as soon as the form loads ... even into design mode ... so you need to set the picture property for all of your image controls to = "" before deploying. You will need to do this through code because otherwise Access will think you no longer want to display a picture and delete the image control on you, just like you can't make a lable with no text.
Steve
Steve
ASKER
Hmmmmm....okay.
This has nothing to do with my Image PictureType property being set to Linked vs. Embedded?????
I will try doing what you recommended.
This has nothing to do with my Image PictureType property being set to Linked vs. Embedded?????
I will try doing what you recommended.
ASKER
By the way....I just noticed that the error message is coming up exactly 6 times.
This is the same number of Image controls on the form.......a very INTERESTING coincidence........LOL.... ...
This is the same number of Image controls on the form.......a very INTERESTING coincidence........LOL....
absolutley has everything to do with Linked images :-)
ASKER
You say it DOES have something to do with LINKED images?
So LINKED means the Image object is retaining the last known path to the image?
So LINKED means the Image object is retaining the last known path to the image?
ASKER
I tried adding in the following code into my Main Form's ONLOAD event:
Me.ImageCostumeItemAssigne dPicture.P icture = ""
Me.ImagePreviewCostumeImag e.Picture = ""
Me.ImagePreviewPropsImage. Picture = ""
Me.ImagePropsItemAssignedP icture.Pic ture = ""
Me.ImageSearchByPlayCostum ePicturePr eview.Pict ure = ""
Me.ImageSearchByPlayPropPi cturePrevi ew.Picture = ""
The same problem still happens when I deploy the MDB to another machine.
Me.ImageCostumeItemAssigne
Me.ImagePreviewCostumeImag
Me.ImagePreviewPropsImage.
Me.ImagePropsItemAssignedP
Me.ImageSearchByPlayCostum
Me.ImageSearchByPlayPropPi
The same problem still happens when I deploy the MDB to another machine.
ASKER
compacting and repairing the MDB on the machine I am deploying to also does nothing to prevent the problem.
The path to MY originating folder is embedded somewhere inside the MDB......
The path to MY originating folder is embedded somewhere inside the MDB......
ASKER
It seems that whatever is happening is happening before the Form OnLoad( ) event is invoked......
So LINKED means the Image object is retaining the last known path to the image?
Yes
I made a function that you need to run BEFORE deploying. Make sure the form is closed first. The code opens the form in design mode, changes the Picture poerty to "" and saves the form.
Public Function CleanUp()
Dim aob As AccessObject
Dim frm As Access.Form
For Each aob In CurrentProject.AllForms
DoCmd.OpenForm aob.Name, acDesign
Set frm = Forms(aob.Name)
If frm.Name = "FormMain"
frm.ImageCostumeItemAssign edPicture. Picture = ""
frm.ImagePreviewCostumeIma ge.Picture = ""
frm.ImagePreviewPropsImage .Picture = ""
frm.ImagePropsItemAssigned Picture.Pi cture = ""
frm.ImageSearchByPlayCostu mePictureP review.Pic ture = ""
frm.ImageSearchByPlayPropP icturePrev iew.Pictur e = ""
DoCmd.Close acForm, frm.Name, acSaveYes
End If
Next
End Function
Steve
Yes
I made a function that you need to run BEFORE deploying. Make sure the form is closed first. The code opens the form in design mode, changes the Picture poerty to "" and saves the form.
Public Function CleanUp()
Dim aob As AccessObject
Dim frm As Access.Form
For Each aob In CurrentProject.AllForms
DoCmd.OpenForm aob.Name, acDesign
Set frm = Forms(aob.Name)
If frm.Name = "FormMain"
frm.ImageCostumeItemAssign
frm.ImagePreviewCostumeIma
frm.ImagePreviewPropsImage
frm.ImagePropsItemAssigned
frm.ImageSearchByPlayCostu
frm.ImageSearchByPlayPropP
DoCmd.Close acForm, frm.Name, acSaveYes
End If
Next
End Function
Steve
ASKER
Getting a syntax error when comiling the code after pasting in your function:
If frm.Name = "FormMain"
says syntax error
If frm.Name = "FormMain"
says syntax error
ASKER
Oh.....forgot the THEN:
Public Function CleanUp()
Dim aob As AccessObject
Dim frm As Access.Form
For Each aob In CurrentProject.AllForms
DoCmd.OpenForm aob.Name, acDesign
Set frm = Forms(aob.Name)
If frm.Name = "FormMain" Then
frm.ImageCostumeItemAssign edPicture. Picture = ""
frm.ImagePreviewCostumeIma ge.Picture = ""
frm.ImagePreviewPropsImage .Picture = ""
frm.ImagePropsItemAssigned Picture.Pi cture = ""
frm.ImageSearchByPlayCostu mePictureP review.Pic ture = ""
frm.ImageSearchByPlayPropP icturePrev iew.Pictur e = ""
DoCmd.Close acForm, frm.Name, acSaveYes
End If
Next
End Function
Public Function CleanUp()
Dim aob As AccessObject
Dim frm As Access.Form
For Each aob In CurrentProject.AllForms
DoCmd.OpenForm aob.Name, acDesign
Set frm = Forms(aob.Name)
If frm.Name = "FormMain" Then
frm.ImageCostumeItemAssign
frm.ImagePreviewCostumeIma
frm.ImagePreviewPropsImage
frm.ImagePropsItemAssigned
frm.ImageSearchByPlayCostu
frm.ImageSearchByPlayPropP
DoCmd.Close acForm, frm.Name, acSaveYes
End If
Next
End Function
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Steve:
Let me say 2 things:
1) THANK YOU....your solution works great.
2) This is really HOKEY to have to do this!!! It works....but seems like kind of a kludge.
Let me say 2 things:
1) THANK YOU....your solution works great.
2) This is really HOKEY to have to do this!!! It works....but seems like kind of a kludge.
ASKER
So if I call this Function on FORM CLOSE........would that be a reliable way to deploy and not have to remember to run this function every time?
I'll test this.....
I'll test this.....
yup ... but if you ask MS ... "works as designed"
I look at these kind of things as exceptions and as long as I can work around them I thnk it is ok (notice ok is lower case) because they did so many other things well.
I look at these kind of things as exceptions and as long as I can work around them I thnk it is ok (notice ok is lower case) because they did so many other things well.
Running the code in the close event depends on your target audience ... if you are deploying to runtime only client this code will not work for them so I would say test using no code (I'm not sure it will save what you set) and then test using your code in the Close event.
Steve
Steve
ASKER
Thanks.
Steve