Solved

Checkbox true if attachment in record

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

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
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 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…

739 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