Solved

Checkbox true if attachment in record

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

840 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