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

If Statement with picture

Status
Not open for further replies.

ClydeData

Technical User
Feb 6, 2003
141
GB
I want to use an if statement with a picture

If picture A exists use A
Else use B (comes from other table)

I am doing it in the SQL of the forms record source with standerd IF statement

 
You need to run the code to see if the file exits, regardless of it is a picture, txt, etc..

Here is example from help..

"Dir Function Example
This example uses the Dir function to check if certain files and directories exist. On the Macintosh, “HD:” is the default drive name and portions of the pathname are separated by colons instead of backslashes. Also, the Microsoft Windows wildcard characters are treated as valid file-name characters on the Mac. However, you can use the MacID function to specify file groups.

Dim MyFile, MyPath, MyName
' Returns "WIN.INI" (on Microsoft Windows) if it exists.
MyFile = Dir("C:\WINDOWS\WIN.INI")

' Returns filename with specified extension. If more than one *.ini
' file exists, the first file found is returned.
MyFile = Dir("C:\WINDOWS\*.INI")

' Call Dir again without arguments to return the next *.INI file in the
' same directory.
MyFile = Dir

' Return first *.TXT file with a set hidden attribute.
MyFile = Dir("*.TXT", vbHidden)

' Display the names in C:\ that represent directories.
MyPath = "c:\" ' Set the path.
MyName = Dir(MyPath, vbDirectory) ' Retrieve the first entry.
Do While MyName <> &quot;&quot; ' Start the loop.
' Ignore the current directory and the encompassing directory.
If MyName <> &quot;.&quot; And MyName <> &quot;..&quot; Then
' Use bitwise comparison to make sure MyName is a directory.
If (GetAttr(MyPath & MyName) And vbDirectory) = vbDirectory Then
Debug.Print MyName ' Display entry only if it
End If ' it represents a directory.
End If
MyName = Dir ' Get next entry.
Loop

&quot;

It seems to cover the basis. If it doesnt work in the form you may have to add this little module to check it for you.

Jeremy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top