Button Attaching Documents to Forms

darkstar257

Registered User.
Local time
Today, 15:27
Joined
Jan 6, 2011
Messages
77
I'm trying to use this API in my database to be able to attach documents to my forms.
http://access.mvps.org/access/api/api0001.htm

Do I have to put this into its own Module? I'm not familiar with how the code is defining Types and declaring Global variables.
 
I am trying to understand what you mean by attach documents to your forms. If you mean attach a document to an entry on a table/form then the FileDialog method is a LOT easier.

Use this code on a command Button OnClick event

Dim BrwsFl As FileDialog

Set BrwsFl = Application.FileDialog(msoFileDialogFilePicker)

With BrwsFl
.Show
.AllowMultiSelect = False
End With

If BrwsFl.SelectedItems.Count = 0 Then
MsgBox "nothing selected"
'what you want to do
End If

Me.DocumentField = BrwsFl.SelectedItems(1)
 
Thanks, this method is much easier.

But I am getting an error some times saying:

This Expression is typed incorrectly or is too complex to be evaluated. For, Example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables.

when certain hyperlinks are assigned to the table.
 
Last edited:
could you post one of the hyperlinks that generates this error?
 
could you post one of the hyperlinks that generates this error?
Here is the link.

\\RFD-main\Users\DataG\my documents\DCEN212.JPG

This seems to happen only when i try to attach a link of a file on my own computer. All the computers are on a network. If i attach files that are on the network it doesn't seem to reject the link like it does on the local files.

Second issue I have is that when I pull up this table using a Subform, the subform just goes blank when I re-open the main form after I attach a file. This is from a Run Time error 2467:

The expression you entered refers to an object that is closed or doesn't exist.

It seems that once I "attach" a file using the button, and close and go back into the form, the Subform unbinds itself for some reason. And even if I delete the subform and recreate it again, the subform will always show up as a blank white box. This appears to be a bug in Access 2003?
 
what is the field type in the table and what type of control are you using on the form for the hyperlink?
 

Users who are viewing this thread

Back
Top Bottom