Solved

Checkbox true if attachment in record

Posted on 2015-02-23
2
129 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now