Solved

Checkbox true if attachment in record

Posted on 2015-02-23
2
151 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 51

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

617 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