image path and and partial image name

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi:
I am thinking to get some images from other folder to my Product Form.

My problem is: my image name is like this: productCode_productName.jpg, such
as: ABC001_super drink 250ml.jpg, or AAF003_ArtAFace Cream 50g.jpg, the
productCode is unique, can I write some code to show this image on my form
only using the image's partial name: ABC001

Such as: the path is: c:\mydocument\imagefolder\"ABC001*.jpg"

Thanks.

James
 
Yes, do a DIR first to get the full name and use what is returned to access
the file.
 
Thanks, Wayne

The form I have will show thousands of products, the productCode is created
when we get product infomation from suppliers, the productCode will be added
manually on each image name. ( ie: ABC001_super drink 250ml.jpg), those
images are stored in different folder according to supplier names.

The image path can be a fixed string, c:\mydocument\supplierName\, after
that I only need the partial image name (which is productCode) to open the
image.

Hopefully it makes clear.

Can you tell me what DIR means, any example? Haven't touch Access for one
year, and my memory is fading. Thanks a lot.

James
 
DIR is a VBA command that does the same thing as the DOS DIR command. If you
give it parameters, it will use those. If you call it again without
parameters, it will find the next file in the directory that matches the
previous parameters.

Example:
strFileName = Dir("c:\mydocument\supplierName\" & Me.txtProductCode & "*")

This will return only the file name, you will have to concatenate the path
in again when you go to use it. If no file is found, DIR returns an empty
string ("").

Sample from the immediate window (Ctrl+G):
?dir("c:\autoexec.bat")
AUTOEXEC.BAT
 
Back
Top