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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lookup of corresponding file names 3

Status
Not open for further replies.

reg999

Technical User
Jan 17, 2005
37
US
I have a database of sales records. I keep invoice numbers in a table and scanned images of hand written invoices as .pdf files in a directory on the hard drive.

I would like to list all of my sales and have the list show whether there is an existing .pdf file that corresponds with each record.

What is the easiest way to go about this?

Table field name: InvNo
Records: 4200, 4201, 4202, etc.

Invoice Directory (folder) on C:
Files: 4200.pdf, 4201.pdf, 4202.pdf, etc.

Thank you,
Reg'
 
Perhaps with a UserDefinedFunction ?
In a standard code module:
Code:
Public ExistsScan(varInvNo) As Boolean
If Trim(varFileName & "") <> "" Then
  ExistsScan = (Dir("C:\Invoice Directory\" & varInvNo & ".pdf") <> "")
End If
End Function
And now the SQL code:
Code:
SELECT InvNo, ExistsScan([InvNo]) As [Scanned?]
FROM yourTable

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I put the module code (with the correct directory) in a new database module, and named it 'ExistsScan', but I must have misunderstood.

When running the SQL, I get "Undefined function 'ExistsScan' in expression.

Sorry, for the elementary mistake.
Reg
 
A module can't have the same name as a procedure, so rename it.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I thought that might be the case. With a different name, I get "Compile error. in query expression 'ExistsScan([InvNo])'."

Is there anything else that I need to substitute in your expressions? I have substituted the Directory containing the files, the table name containing 'InvNo', and [Scanned?] with an arbitrary name 'Scn'.
 
Renamed the Module to 'Fscan1'

Also, I'm getting an error on the 'varFileName'. Do I need to substitute something else there?
 
yes, there is no varFileName - change that to varInvNo
 
OOps, sorry for the typo :~/
Code:
Public ExistsScan(varInvNo) As Boolean
If Trim([!]varInvNo[/!] & "") <> "" Then
  ExistsScan = (Dir("C:\Invoice Directory\" & varInvNo & ".pdf") <> "")
End If
End Function

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
This will work great! Thank you both for all of the assistance.
Reg'
 
I know that this is off topic, and not in keeping with the forum guidelines, but to PHV, you have generously helped me out of several 'binds', of which I have benefited in one form or another. I would be very pleased to have a nice single malt or bottle of 'Chateau something or other' purchased for you at a location of your choice.

Indebted,
Reg'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top