Results 1 to 10 of 10
  1. #1
    sailinxtc is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2008
    Posts
    5

    Setting paths different for each form


    I have two forms and each can display pictures in an umbound image frame based on the record. I need to have a directory within the current projects to keep the pictures seperate for each form. Everything is working with the pictures in the same folder the database opens from, but wasn't able to figure out the correct VB code. I am using the example microsoft referenced for "on Current", should it be done on each form or use a if statement somewhere else

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    CurrentProject.Path return the complete path to the current folder which you can then add your & "\PictureFolder1\Pic1.jpg" to. Does that help?

  3. #3
    sailinxtc is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2008
    Posts
    5

    Existing code

    This is what I am using that works for the current directory.

    Private Sub Form_AfterUpdate()
    Call DisplayImage(Me.ImageFrame, Me!txtImageName & ".jpg")
    End Sub
    Private Sub Form_Current()
    Call DisplayImage(Me.ImageFrame, Me!txtImageName & ".jpg")
    End Sub

    Thanks for pointing me in the right direction, I will play around with it and see what I can come up with

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Can you post the code for the DisplayImage procedure?

  5. #5
    c_smithwick is offline Underpaid Programmer
    Windows 7 Access 2003
    Join Date
    Jan 2010
    Location
    Lakeside, CA
    Posts
    49
    Have you tried including the path in your DisplayImage procedure call?

    Code:
    Private Sub Form_AfterUpdate()
        Call DisplayImage(Me.ImageFrame, strPathToPicture & "\" & Me!txtImageName & ".jpg")
    End Sub
    Private Sub Form_Current()
        Call DisplayImage(Me.ImageFrame,  strPathToPicture & "\" & Me!txtImageName & ".jpg")
    End Sub

  6. #6
    sailinxtc is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2008
    Posts
    5

    setting the current path Relative

    Thats similar to what I was trying, I think where i am having my issue is setting the actual path. I am able to get it to work if i reference the whole path i.e. strToPicturePath = "C:\Documents and Settings\Owner\My Documents\DB\Picture1" but need to use the equavalent of ./picture1 with DB being the current project directory. My concern is using the project in differnt opperating systems, the path will be different for each, if that makes sense. simply my lack of experience on this... thanks...

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    So:
    Call DisplayImage(Me.ImageFrame, CurrentProject.Path & "\" & Me!txtImageName & ".jpg")
    ...should work, right?

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Or maybe:
    Call DisplayImage(Me.ImageFrame, CurrentProject.Path & "\Picture\" & Me!txtImageName & ".jpg")
    ...if you want to specify a subdirectory off of the current directory. If each form has a different subdirectory then I would probably set a public variable in the OnLoad event of each form.

  9. #9
    sailinxtc is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2008
    Posts
    5

    Both ways worked

    Thank you for your help both ways work, but am going to use the onload event as you mentioned. thanks much...

  10. #10
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    So are you ready to follow the link in my sig and mark this thread as Solved?

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Setting NOT NULL for an column
    By cwwaicw311 in forum Forms
    Replies: 1
    Last Post: 02-21-2010, 10:30 PM
  2. Setting Focus on a Form
    By MFeightner in forum Forms
    Replies: 1
    Last Post: 07-30-2009, 07:49 AM
  3. Setting a field to be dependent on another
    By CushingMT in forum Forms
    Replies: 0
    Last Post: 11-19-2008, 11:51 AM
  4. problem setting Excel sheet name in vba from a form
    By dataman in forum Programming
    Replies: 2
    Last Post: 04-18-2006, 07:26 AM
  5. Setting combo box properties
    By rathfam4 in forum Programming
    Replies: 1
    Last Post: 12-28-2005, 02:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums