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

recordset limited by If FileExists 1

Status
Not open for further replies.

diwin

Technical User
Nov 29, 2002
218
0
0
CA
Hi.

I want to print plant labels with pictures, but only for those records for which a picture exists.

How do I create a recordsource or query for a report that captures only plant records with pictures? I want to use the recordset/query as the basis for printing labels from the report and for deleting only those printed from the temp table that is the printing queue, so that those remaining in the queue can be printed on a different type of label without picture.

I can use fso and fileExists ok. I just don't know how to use it to limit records captured by a recordset/query.

Daniel Dillon
O o . (<--- brain shrinking at rate shown.)
 
How are ya diwin . . .

I take it your validating Path & FileNames for a field in the query that holds this info?

Add a [purple]custom field[/purple] to the query that calls a function which returns true/false accordingly. [blue]Criteria[/blue] for the field would of course be set to [blue]True[/blue].

The custom field would look like:
Code:
[blue]FileStat:FileOK([pathfieldname])[/blue]
Function would look like:
Code:
[blue] Public Function FileOK(PathFile As String) As Boolean

   If FileExists Then
      FileOK = True
   Else
      FileOK = False
   End If

End Function[/blue]
[blue]Your Thoughts? . . .[/blue]

Calvin.gif
See Ya! . . . . . .
 
The pictures are named with the plant ID + "_200.jpg" to denote size. So, does it go like this?

Code:
FileStat:FileOK([b][ID][/b])

Public Function FileOK(PathFile As String) As Boolean

Dim objfso As Object
Set objfso = CreateObject("Scripting.FileSystemObject")
pathname = CurrentProject.Path
imagesfolderpath = pathname & "\LargePics\"

If objfso.FileExists(imagesfolderpath & PathFile & "_200.jpg") Then
FileOK = True
Else
FileOK = False
End If

Set objfso = Nothing

End Function

[/code]




Daniel Dillon
O o . (<--- brain shrinking at rate shown.)
 
diwin . . .

If [blue]ID[/blue] is the fieldname for [blue]plant ID[/blue] it looks fine.

Have you tried to open the query indendently yet?

As a test move one of the pictures out of the default folder . . .

Calvin.gif
See Ya! . . . . . .
 

That did the trick! Thanks TheAceMan1.

Daniel Dillon
O o . (<--- brain shrinking at rate shown.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top