Question : How do I open .jpg files with VBA code using wildcards

I have one MS Access db tool that stores a pictures filename, and using that, the user can click a button which will bring up a form window to view a linked picture using that filename.

I am currently working on another Access db tool where I also want to allow the user to be able to click a button and open a picture.  Each record in the parent table has a unique record code which appears in a combobox on my main form and is user selectable.  The legacy photos for these records are all uniquely named using the record code as a prefix, and then some other text which isn't necessarily predictable. (The filenames for these pictures are not stored with each record as in the db tool first mentioned.)  Is there a way to use wildcards so that I can call for the photo using only the unique prefix in its filename and ignoring what comes after that?

The filenames are like:

uniquerecordcode_xxxx.jpg

where xxxx is a variable length string and is always preceeded by a "_".

Thanks,  me

Answer : How do I open .jpg files with VBA code using wildcards

(The filenames for these pictures are not stored with each record as in the db tool first mentioned)
where are pictures stored?

assuming the path to the pictures is "c:\myPictures"

you can get the complete filename with this code

dim picFile as string,picPath as string
picPath="c:\myPictures"
picFile=dir(picPath & "\" & me.comboName & "_*.jpg")




Random Solutions  
 
programming4us programming4us