none
get a Photo from a Directory based on "Category" and "Photo number" by using the ControlSource on a Form RRS feed

  • Question

  • Hello, in the database I'm trying to create there are a table with Photo numbers and a table with the Category of the Photos such as: Cars, Motorbikes and Bicycles. The Photos are located in a file in the same Directory as the Access Database. On a Form I have inserted a Photo box with the ControlSource: 

    =[CurrentProject].[Path] & "\Cars\" & [Photonumber] & ".jpg" On the form the Photo is shown related to the file "Cars" and the Photo number. So far so good. But there are several Categories of Photos. So I like to make the Photo that should be showed related to "Category" and "Photo number". My question is: can this be done in the syntaxis of the ControlSource?

    <o:p style="">I tried the following in several variations (Like"\" & [Category] &"\") without any success</o:p>

    =[CurrentProject].[Path] & [Category] & [Photonumber] & ".jpg"


    Tuesday, February 4, 2020 3:07 PM

Answers

  • Hi lmb,

    I found out why it doesn't work. I had the same problem with combining text fields in a Report and Form. Combining text fields in a Report or Form need to be done from the "main" Table. So I selected the records directly from the main Table and it works. Like this: in the Table "Merfabrikant" are some Manufacturers. in the Table "Model" I make a selection from the Table "Merkfabrikant". When I want to combine records in a Report or Form I need to select the records direct from the Tabel "Merkfabrikant". 

    The same Trick is used for my initial problem with the Photo's in different Categories. That's working now also.

    Verzamelaar

    • Marked as answer by Verzamelaar Friday, March 27, 2020 9:06 AM
    Thursday, March 26, 2020 2:00 PM

All replies

  • =[CurrentProject].[Path] & [Category] & [Photonumber] & ".jpg"


    Hi Verzamelaar,

    You could try:   = CurrentProject.Path & "\" & Category & "\" & Photonumber & ".jpg"

    Imb.

    Tuesday, February 4, 2020 3:13 PM
  • Thanks for your reply. I filled in: = CurrentProject.Path & "\" & [Category] & "\" & [Photonumber] & ".jpg"

    Unfortuanally no result.

    Any other Idea?

    Tuesday, February 4, 2020 10:46 PM
  • Any other Idea?

    Hi Verzamelaar,

    Is "Categorie" the name of a map in the CurrentProject.Path , as I assumed? Or is the Categorie part of the filename?

    How do you distinguish between the different Categories on file level?

    Imb

    Tuesday, February 4, 2020 11:13 PM
  • Hi Imb,

    Category is the table with the name of the folders, like Cars, Motorbikes. The Folders are in the same Directory as the Database. Like c:\user\cars\photos and c:\user\motorbikes\photos

    The Photos only have a Number that is Part of the Table Photonumbers. This Number is on a small Sticker on the Model and is unique in each Category. 

    I hope this is a better description.

    Verzamelaar

    Wednesday, February 5, 2020 11:22 AM
  • Category is the table with the name of the folders, like Cars, Motorbikes. The Folders are in the same Directory as the Database. Like c:\user\cars\photos and c:\user\motorbikes\photos

    Hi Verzamelaar,

    It seems that you have an additional map "photos".

    So try:     = CurrentProject.Path & "\" & Category & "\Photos\" & Photonumber & ".jpg"

    Imb.


    • Edited by Imb-hb Wednesday, February 5, 2020 12:28 PM
    Wednesday, February 5, 2020 12:28 PM
  • Hi lmb,

    Sorry lmb, I could better gave the next example of the directory of the Photos:

    c:\user\cars\301.jpg and c:\user\motorbikes\156.jpg

    So there is no folder Photos. I meant the real numbers of the Photos.

    It is possible that in the Folder "cars" and in the Folder "motorbikes" the same Photo number exists so it's necessary to use different Folders

    Sorry for the confusion.

    Verzamelaar

    Wednesday, February 5, 2020 3:42 PM
  • 1: c:\user\cars\301.jpg and c:\user\motorbikes\156.jpg

    ...

    2: It is possible that in the Folder "cars" and in the Folder "motorbikes" the same Photo number exists so it's necessary to use different Folders

    Hi Verzamelaar,

    1. If these file specifications are the correct ones, then you should find the files with

            = CurrentProject.Path & "\" & Category & "\" & Photonumber & ".jpg"

    under the condition that CurrentProject.Path = "c:\user", Category = "Cars", and Photonumber = 301.

    I don't know why it would not work in the first try.

    2. In principle you can use different folders with the same Photonumbers. As long as the whole filespecification is unique, you will find the right .jpg file. But personally I would not recommend this, as it can lead to confusion. If all the Photonumbers are unique, you can place them in the same folder, or in different, just what you want. For the database it is not of interest, as long as the file-specification is unique.

    If you keep the Photonumbers unique, you can also see is as a "verzameling" of photo's, each with its own Category. But besides the Category you can also add other features, independent of the Category: Year of construction, Brand, Fueltype, maximum speed, etc., etc.

    Imb.

    Wednesday, February 5, 2020 7:05 PM
  • Hi lmb,

    It's strange indeed that it doesn't work.

    I think i wil follow your idea to make all the Photo numbers unique. Makes it more simple.

    Thanks very much for your support.

    Verzamelaar

    Wednesday, February 5, 2020 9:14 PM
  • Hi Verzamelaar,

    Success with your project.

    In which city do you live? I am from the neighbourhood of Eindhoven.

    Imb.

    Wednesday, February 5, 2020 9:26 PM
  • Hi lmb,

    I live in Apeldoorn.

    I have some experience with Excel and VBA. Now I'm making a Database to manage my collections. It's very nice and interesting to explore Access, with some help of course.

    Verzamelaar 

    Wednesday, February 5, 2020 10:27 PM
  • Hi lmb,

    I found out why it doesn't work. I had the same problem with combining text fields in a Report and Form. Combining text fields in a Report or Form need to be done from the "main" Table. So I selected the records directly from the main Table and it works. Like this: in the Table "Merfabrikant" are some Manufacturers. in the Table "Model" I make a selection from the Table "Merkfabrikant". When I want to combine records in a Report or Form I need to select the records direct from the Tabel "Merkfabrikant". 

    The same Trick is used for my initial problem with the Photo's in different Categories. That's working now also.

    Verzamelaar

    • Marked as answer by Verzamelaar Friday, March 27, 2020 9:06 AM
    Thursday, March 26, 2020 2:00 PM
  • If you want to stop chasing folders/files you can store the images on your database (size permitting unless you change engine) 

    Check my article here : https://www.experts-exchange.com/articles/33716/Defeating-the-device-independent-bitmap-dib-format.html

    Monday, April 27, 2020 8:27 AM