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?
LVL 5
Tom KnowltonWeb developerAsked:
Who is Participating?
 
stevbeConnect With a Mentor Commented:
sorry bout that ... I was adapting some code I had to something different but in the same ballpark ... this should work.

Public Function CleanUp()

Dim aob As AccessObject
Dim frm As Access.Form

    For Each aob In CurrentProject.AllForms
        If aob.Name = "FormMain" Then
            DoCmd.OpenForm aob.Name, acDesign
            Set frm = Forms(aob.Name)
            frm.ImageCostumeItemAssignedPicture.Picture = ""
            frm.ImagePreviewCostumeImage.Picture = ""
            frm.ImagePreviewPropsImage.Picture = ""
            frm.ImagePropsItemAssignedPicture.Picture = ""
            frm.ImageSearchByPlayCostumePicturePreview.Picture = ""
            frm.ImageSearchByPlayPropPicturePreview.Picture = ""
            DoCmd.Close acForm, frm.Name, acSaveYes
            Exit For
       End If
    Next

End Function


Steve
0
 
stevbeCommented:
that is truely bizarre ... is there any issues with MISSING references? have you repaired/compact recently, does everything compile OK?

Steve
0
 
Tom KnowltonWeb developerAuthor Commented:
I've run compact and repair and compiled  **just before** distributing the app......same problem.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
Tom KnowltonWeb developerAuthor Commented:
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.
0
 
stevbeCommented:
just for testing .... does CurrentDb.Name tell you the correct location?

Steve
0
 
Tom KnowltonWeb developerAuthor Commented:
>>>ust for testing .... does CurrentDb.Name tell you the correct location?

Let me check that....it'll take me a few minutes...
0
 
stevbeCommented:
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
0
 
Tom KnowltonWeb developerAuthor Commented:
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.
0
 
Tom KnowltonWeb developerAuthor Commented:
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.......
0
 
stevbeCommented:
absolutley has everything to do with Linked images :-)
0
 
Tom KnowltonWeb developerAuthor Commented:
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?
0
 
Tom KnowltonWeb developerAuthor Commented:
I tried adding in the following code into my Main Form's ONLOAD event:

 Me.ImageCostumeItemAssignedPicture.Picture = ""
    Me.ImagePreviewCostumeImage.Picture = ""
    Me.ImagePreviewPropsImage.Picture = ""
    Me.ImagePropsItemAssignedPicture.Picture = ""
    Me.ImageSearchByPlayCostumePicturePreview.Picture = ""
    Me.ImageSearchByPlayPropPicturePreview.Picture = ""

The same problem still happens when I deploy the MDB to another machine.
0
 
Tom KnowltonWeb developerAuthor Commented:
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......
0
 
Tom KnowltonWeb developerAuthor Commented:
It seems that whatever is happening is happening before the Form OnLoad(   )   event is invoked......
0
 
stevbeCommented:
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.ImageCostumeItemAssignedPicture.Picture = ""
            frm.ImagePreviewCostumeImage.Picture = ""
            frm.ImagePreviewPropsImage.Picture = ""
            frm.ImagePropsItemAssignedPicture.Picture = ""
            frm.ImageSearchByPlayCostumePicturePreview.Picture = ""
            frm.ImageSearchByPlayPropPicturePreview.Picture = ""
            DoCmd.Close acForm, frm.Name, acSaveYes
        End If
    Next

End Function

Steve
0
 
Tom KnowltonWeb developerAuthor Commented:
Getting a syntax error when comiling the code after pasting in your function:

If frm.Name = "FormMain"


says syntax error
0
 
Tom KnowltonWeb developerAuthor Commented:
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.ImageCostumeItemAssignedPicture.Picture = ""
            frm.ImagePreviewCostumeImage.Picture = ""
            frm.ImagePreviewPropsImage.Picture = ""
            frm.ImagePropsItemAssignedPicture.Picture = ""
            frm.ImageSearchByPlayCostumePicturePreview.Picture = ""
            frm.ImageSearchByPlayPropPicturePreview.Picture = ""
            DoCmd.Close acForm, frm.Name, acSaveYes
        End If
    Next

End Function
0
 
Tom KnowltonWeb developerAuthor Commented:
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.
0
 
Tom KnowltonWeb developerAuthor Commented:
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.....
0
 
stevbeCommented:
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.
0
 
stevbeCommented:
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
0
 
Tom KnowltonWeb developerAuthor Commented:
Thanks.
0
All Courses

From novice to tech pro — start learning today.