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

How to get AttachmentCount from a field in a table

Status
Not open for further replies.

OzFoxy

Programmer
Dec 20, 2008
26
AU
Hi Team, my Asset Register DB has a table which includes the following fields:
A yes/no field [Image] to indicate if a Photo is required.
An attachment field to contain the photo [Photo]
In the form code, me!Photo.attachmentcount returns 0 or 1 for the current record, no attachments or one attachment (I assume).
I need to get the attachmentcount from the table in VBA code, and/or in a query and/or in the filter for a report.
I can't work out the code required. For example:

With rstTemp1
While not .eof
If !Image = true then
???? code needed to get the attachmentcount from the !Photo field
... more code
end if
.movenext
wend
end with

Thanks in advance for the help.
I'm feeling really dumb right now.

 
If "[tt]me!Photo.attachmentcount[/tt] returns 0 or 1 for the current record, no attachments or one attachment ", then I would try:

Code:
With rstTemp1
    While not .eof
        If !Image = true then
            [blue]MsgBox !Photo.attachmentcount[/blue]
            ... more code
         end if
        .movenext
    wend
end with

Assuming the Photo field is in your rstTemp1 recordset.

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Thanks Andrzejek, but that code produces the error 'Run time error 438: Object doesn't support this property or method'.
It is apparent that the property 'AttachmentCount' is only supported on form controls.
I worked around the problem by creating a form just for the 'Attachment' type field, and cycled through all the records.
That allowed me to access the attachmentcount property as well as the filename, data, and filetype properties.
Messy, but it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top