Unbound Attachment Field (1 Viewer)

TajikBoy

Member
Local time
Yesterday, 16:01
Joined
Mar 4, 2011
Messages
82
Good morning/afternoon/evening guys,

I want to place a field (unbound) on my form (Unbound), which will display a record from another table which contains one record with an attachment, to serve the said file as template so user can open, use and save somewhere else

How can I link this unbound attachment field to the table contains the record?
 

isladogs

MVP / VIP
Local time
Today, 00:01
Joined
Jan 14, 2017
Messages
18,217
Bind it... Or use DLookup as an alternative.
Also bear in mind that attachment fields cause bloat and aren't recommended by most developers.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 07:01
Joined
May 7, 2009
Messages
19,237
what file type is the Attachment?

you can have a Text column for your table that will Hold the Path (fixed location) of the
Modified attachment file.

you can have an Image control on the form.
add code to the Click event to Extract (on a Fixed location) and Show the
Attachment.
 

TajikBoy

Member
Local time
Yesterday, 16:01
Joined
Mar 4, 2011
Messages
82
what file type is the Attachment?

you can have a Text column for your table that will Hold the Path (fixed location) of the
Modified attachment file.

you can have an Image control on the form.
add code to the Click event to Extract (on a Fixed location) and Show the
Attachment.
Hi Arnel.......

Its an excel file - i just want user to open the file, no save back

add code to the Click event to Extract - what would be the code, not that expert like you guys , yet.....
 

TajikBoy

Member
Local time
Yesterday, 16:01
Joined
Mar 4, 2011
Messages
82
Bind it... Or use DLookup as an alternative.
Also bear in mind that attachment fields cause bloat and aren't recommended by most developers.

Used Dlookup but didnt work, also placed in on load event to populate, gave runtime error 438 Object doesn't support this property or method

FOr this field, there's no write back, single record, holding a template file
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 07:01
Joined
May 7, 2009
Messages
19,237
see this demo.
 

Attachments

  • sampleAttach.accdb
    1.1 MB · Views: 342

TajikBoy

Member
Local time
Yesterday, 16:01
Joined
Mar 4, 2011
Messages
82
see this demo.

Thanks Arnel, that looks awesome but, my aim is not to save the file somewhere, just put the attachment from tblADCB to the unbound field on the form called ADCB

With my limited experience on VBA, I extracted below, which I assume takes the attachment and saves it, but instead of saving, I want it in the unbound field

Set db = CurrentDb
Set rsP = db.OpenRecordset("select top 1 * from tblADCB;", dbOpenDynaset)
With rsP
If Not (.BOF And .EOF) Then
.MoveFirst
'open the attachment field as recordset
Set rsC = .Fields("ADCBFile").Value
ADCB = rsC <---- in here I need the attachment in ADCB
Set rsC = Nothing
End If
.Close
End With
Set rsP = Nothing
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 19:01
Joined
May 21, 2018
Messages
8,527
Make it a subform with just the attachment field and navigate to that field.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 07:01
Joined
May 7, 2009
Messages
19,237
you can also use a Bound Single form if that is your ultimate goal and not post#1 (unbound).
 

Users who are viewing this thread

Top Bottom