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
Solved

Checkbox true if criteria exists

Posted on 2014-01-08
2
443 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
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
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…

839 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