Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Retrieve filename in query

Status
Not open for further replies.

blueangel76

Technical User
Feb 15, 2007
11
US
I have a table in access with a field named UPC containing UPC codes. I have a folder with image files named according to their corresponding UPC code. I need to run a query that returns either the image filename that matches the UPC code or actually shows the image(s) associated with that UPC code. Is there a way to do either, possibly using Scripting.FileSystemObject or some other script or query code?
 
Welcome to Tek Tips!

You can get the file name from the table using a simple [red]Select query[/red] or use VBA and open a [red]ADO or DAO [/red]recordset or user [red]DLookup[/red].

As far as finding and opening the associated file the [red]FileSystemObject[/red] would be one way. You could also use the [red]Dir[/red] function I think. If you do a keyword search on any of the above [red] red [/red] words you should find lots of posts to get you started.

These are only a few ways to do what you are asking.

I tried to have patience but it took to long! :) -DW
 
blueangel76,
Dir?
Code:
SELECT [UPC], Dir("[i]C:\My Folder\UPC\[/i]"&[UPC]&"[i].img[/i]") AS Expr1 FROM MyTable;

You could use Expr1 as the [tt]ControlSource[/tt] for an Image control on a form.

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top