Checking for attached file

JordanR

Registered User.
Local time
Today, 13:11
Joined
Jan 25, 2005
Messages
72
I would have thought this was easy, but I keep getting an error.
I have a form with a save button. When the save button is clicked, I want it to check if user has attached an OLE object to a bound object frame. If they have, I'd like a checkbox to be true.
Here's the code I tried:
If Attachment.LpOleObject = 0 Then
Attach.Value = False
Else
Attach.Value = True
End If
This seems so incredibly straight forward and it does work if there is an attachment. If there isn't I get the message that my database can't retrieve the value of this property.

Any help would be greatly appreciated.
 
Do you execute this code before you actually save the record?

If so, try moving the code to follow the code that actually saves the record.

Just a thought.
 
Maybe...

Do you get a 13 Type Mismatch error?
You might be comparing an object type to an integer, so try using the object equivalent of zero, or 'Nothing'

one liner...

Attach.Value = Not (Attachment.LpOleObject Is Nothing)

or, using an if block...

If Attachment.LpOleObject Is Nothing Then
Attach.Value = False
Else
Attach.Value = True
End If
 
I am saving before I do the check, so that's not it. /sigh.
Lagbolt,
I wasn't getting a type mismatch on the check. The error was simply that it couldn't get the property. I tried both your ideas and they did give me a type mismatch error.

Any other ideas? It can't be that had to see if the field has a value, right?
 

Users who are viewing this thread

Back
Top Bottom