Solved

Checkbox true if criteria exists

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Normalization of a table 19 70
A Function to parse a text string 4 34
Criteria for Date for DCount 4 17
Opening forms with an input box 5 17
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

774 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