Solved

Checkbox true if criteria exists

Posted on 2014-01-08
2
444 Views
Last Modified: 2014-01-08
I have a checkbox on a form named chkbxCurrentCustomer.

I need code in the oncurrent event of the form to check the checkbox true if the contents of the field "FullName" exists in a field named "FullName" in tblCustomers.

Otherwise it should be false.

How can I do this?
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 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 39765819
Try this:


chkMyBox = (Dcount("*", "tblCustomers", "FullName = " & chr(34) & Me.FullName & chr(34)) > 0)

Open in new window


(basically if the count of "FullName" in your table is greater than 0 based on the criteria, check the box otherwise the checkbox is false)
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39765822
So your form is not the based on tblCustomers, is that correct?

You could use something like:

Private Sub Form_Current:

  if me.[FullName] & "" = "" Then
      me.chkbxCurrentCustomer = false
  elseif DCOUNT("*", "tblCustomers", "[FullName] = '" & me.[FullName] & "'") > 0 Then
      me.chkbxCurrentCustomer = true
  Else
       me.chkbxCurrentCustomer = false
   End If

End Sub
0

Featured Post

Independent Software Vendors: 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

Suggested Solutions

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

761 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