Solved

Checkbox true if attachment in record

Posted on 2015-02-23
2
135 Views
Last Modified: 2015-02-24
I have a form with a checkbox and also with an attachment field.  If there is no attachment then I want the checkbox to be false.  If there IS an attachment I want the checkbox to be true.

I've tried this but it doesn't work.  The checkbox is checked no matter what.

    If IsNull(Me.picScannedIDcard) Then
        Me.chkbxHasAttachment = False
        Else
        Me.chkbxHasAttachment = True
    End If

Open in new window

0
Comment
Question by:SteveL13
2 Comments
 
LVL 22

Accepted Solution

by:
Flyster earned 250 total points
ID: 40627200
Try this in the form on current event:
Private Sub Form_Current()
  If Len(Me.Attachment1.FileName) > 0 Then
    Me.Check1.Value = True
  Else
    Me.Check1.Value = False
  End If
End Sub

Open in new window

Just check Attachment1 and Check1 to the correct values.

Flyster
0
 
LVL 49

Assisted Solution

by:Gustav Brock
Gustav Brock earned 250 total points
ID: 40627569
It is much easier to modify the query you use as source for the form.
The attachment field is a multivalue field so use SQL similar to this:

SELECT
    *, [Attachment].[FileName] Is Not Null AS IsFileAttached
FROM
    tblYourTable;

Then bind your checkbox to IsFileAttached.

/gustav
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

785 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question