UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Hiding Empty Attachment Fields On A Form, Access 2010    
 
   
mowatz
post Aug 25 2019, 04:16 AM
Post#1



Posts: 29
Joined: 12-July 09
From: North Carolina


I have created a database for my record collection. In this database I have a form that displays the pictures of the album's cover, front, back and in some cases inner covers. Since the inner covers are not on every album I wanted to hide this field if there were no pictures attached.
First of all is this possible with an Attachment Field type.

The form consists of four fields SleevePicFront, SleevePicFront Inner, SleevePicBackInner, SleevePicBack. I tried using the following If Then statement:

If (SleevePicFrontInner & "") = "" Then
SleevePicFrontInner.Visible = False
Else
SleevePicFrontInner.Visible = True
End If

I compiled the code and received to following error message "Compile error" "Method or data member not found"

I would like to hide the two Inner Fields if possible.
Go to the top of the page
 
missinglinq
post Aug 25 2019, 05:24 AM
Post#2



Posts: 4,634
Joined: 11-November 02



Never worked with these before...but I'd try replacing

If (SleevePicFrontInner & "") = "" Then

with

If (Me.SleevePicFrontInner & "") = "" Then

Also...what kind of Form are you talking about...and where, exactly, are you placing this code?

Linq ;0)>
This post has been edited by missinglinq: Aug 25 2019, 05:25 AM

--------------------
Hope this helps!

The problem with making anything foolproof...is that fools are so darn ingenious!

All posts/responses based on Access 2003/2007
Go to the top of the page
 
theDBguy
post Aug 25 2019, 08:08 AM
Post#3


Access Wiki and Forums Moderator
Posts: 76,317
Joined: 19-June 07
From: SunnySandyEggo


Hi. An Attachment field can store more than one file, so why do you need more than one field for attachments? Also, hiding a control on a form doesn’t get rid of the space it occupies. It would just show up as an empty space.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
missinglinq
post Aug 25 2019, 08:13 AM
Post#4



Posts: 4,634
Joined: 11-November 02



And one would expect multiple images to take up a fair amount of space!

Perhaps having a generic 'No Image Available' image, to be used when there is none to show, would be more appropriate.

Linq ;0)>

--------------------
Hope this helps!

The problem with making anything foolproof...is that fools are so darn ingenious!

All posts/responses based on Access 2003/2007
Go to the top of the page
 
theDBguy
post Aug 25 2019, 09:37 AM
Post#5


Access Wiki and Forums Moderator
Posts: 76,317
Joined: 19-June 07
From: SunnySandyEggo


Hi. Just in case you still want to check for empty attachment fields, check out the AttachmentCount property.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
ADezii
post Aug 25 2019, 11:55 AM
Post#6



Posts: 2,641
Joined: 4-February 07
From: USA, Florida, Delray Beach


I do believe the theDBguy has the right idea. In the Current() Event of your Form:
CODE
Me![SleevePicFrontInner].Visible = (Me![MyPics].AttachmentCount > 3)
Go to the top of the page
 
June7
post Aug 25 2019, 02:01 PM
Post#7



Posts: 812
Joined: 25-January 16



The property setting will affect all instances of control so if form is in Continuous view, all records will hide/not hide control.

If images are in same field then could only be viewed on form by navigating with the Image control navigation tool. This makes building a report a little more complicated for print output. The report would have to use a query that expands the multiple images to individual records. Images would not display on same record row. Hence, the multiple fields.

A "No Image Available" placeholder image is what I have done.

Embedding objects in db uses up Access file size limit. Images can be external and still be loaded into Image control by referencing file path in ControlSource.

This post has been edited by June7: Aug 25 2019, 02:08 PM

--------------------
Attachments Manager is below the edit post window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG! http://www.cpearson.com/Excel/DebuggingVBA.aspx
Go to the top of the page
 
mowatz
post Aug 27 2019, 06:00 AM
Post#8



Posts: 29
Joined: 12-July 09
From: North Carolina


The form in question is activated by a push button on the main Record form and contains only the 4 fields of the 4 pictures. I am using the OnCurrent event for the code.
The default view of the form is Single Form.

I tried using If (Me.SleevePicFront Inner & "") = "" Then but that didn't work either.

The reason I use the attachment field is the size. Using the Access bitmap pictures I would have run out of room along time ago. The pictures I take are reduced to their smallest size. I have have other databases that have thousands of pictures and I have been able to keep the size under 1 GB.

What I was hoping for, was that if I could hide the 2 fields that were empty, they would not be visible on the form and the front and back pictures would be together.
Go to the top of the page
 
Mickjav
post Aug 27 2019, 06:18 AM
Post#9



Posts: 75
Joined: 25-November 18



If Me![SleevePicFront Inner] = "" Then 'Do Something

You could also use

If IsNull(Me![SleevePicFront Inner]) Then Do Something

Or look for a function on the web called IsNothing I use it all the time for testing values

hope it helped mick

P.S. It's really not a good idear to have spaces in your field names it can cause a lot of problems

--------------------
All open code examples and free projects are only available from: Database Dreams
Go to the top of the page
 
mowatz
post Aug 27 2019, 06:45 AM
Post#10



Posts: 29
Joined: 12-July 09
From: North Carolina


There is no space between Front and Inner. I mistyped it.
Go to the top of the page
 
Mickjav
post Aug 27 2019, 08:11 AM
Post#11



Posts: 75
Joined: 25-November 18



Check this out https://docs.microsoft.com/en-us/office/vba...cess.attachment

You could use a recordset2 object to work with the attachments

--------------------
All open code examples and free projects are only available from: Database Dreams
Go to the top of the page
 
June7
post Aug 27 2019, 12:05 PM
Post#12



Posts: 812
Joined: 25-January 16



See posts 5 and 6 for correct code using AttachmentCount property.


--------------------
Attachments Manager is below the edit post window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG! http://www.cpearson.com/Excel/DebuggingVBA.aspx
Go to the top of the page
 
mowatz
post Aug 27 2019, 03:14 PM
Post#13



Posts: 29
Joined: 12-July 09
From: North Carolina


What I'm thinking is that = "" does not apply to an Attachment field. And After checking the link you provided for Microsoft Help Is Null doesn't apply either.
Go to the top of the page
 
theDBguy
post Aug 27 2019, 03:33 PM
Post#14


Access Wiki and Forums Moderator
Posts: 76,317
Joined: 19-June 07
From: SunnySandyEggo


QUOTE (mowatz)
What I'm thinking is that = "" does not apply to an Attachment field. And After checking the link you provided for Microsoft Help Is Null doesn't apply either.

Hi. Just in case you missed them, please review the following links: Post #12, Post #5, and Post #6.

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
mowatz
post Aug 28 2019, 06:27 AM
Post#15



Posts: 29
Joined: 12-July 09
From: North Carolina


I tried that with no success.
Go to the top of the page
 
theDBguy
post Aug 28 2019, 10:07 AM
Post#16


Access Wiki and Forums Moderator
Posts: 76,317
Joined: 19-June 07
From: SunnySandyEggo


QUOTE (mowatz)
I tried that with no success.
Thanks for letting us know. Good luck!

--------------------
Just my 2 cents... "And if I claim to be a wise man, it surely means that I don't know" - Kansas
Access Website | Access Blog | Email
Go to the top of the page
 
June7
post Aug 28 2019, 01:17 PM
Post#17



Posts: 812
Joined: 25-January 16



"No success" means what - error message, wrong result, nothing happens?

It works for me.

If you want help, need to provide info. Post your code. Provide db for analysis.

Else, good luck.

--------------------
Attachments Manager is below the edit post window. To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.
DEBUG! DEBUG! DEBUG! http://www.cpearson.com/Excel/DebuggingVBA.aspx
Go to the top of the page
 
mowatz
post Aug 29 2019, 08:02 AM
Post#18



Posts: 29
Joined: 12-July 09
From: North Carolina


When writing the code as you type in certain commands VB will provide options, like if .Visible is typed in VB shows the options "True" and "False". When typing in the code for AttachmentCount, VB provides no options that should be the available.

The db is too large to upload 184,000 KB

Thanks for all your help.
Go to the top of the page
 
ADezii
post Aug 29 2019, 09:24 AM
Post#19



Posts: 2,641
Joined: 4-February 07
From: USA, Florida, Delray Beach


I am attaching a very simple Demo that will illustrate how you can use the AttachmentCount Property of an Attachment Field to make a Control Visible or Invisible. Hope this helps.
Attached File(s)
Attached File  Attachment_Demo.zip ( 270.91K )Number of downloads: 0
 
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    21st September 2019 - 07:06 PM