1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

True/False Statements in Access

Discussion in 'Other PC Software' started by tjv1960, 2006/01/30.

  1. 2006/01/30
    tjv1960 Contributing Member

    tjv1960 Inactive Thread Starter

    Joined:
    2002/11/26
    Messages:
    32
    Likes Received:
    0
    :eek: I need to make a string of numbers (ssn) turn a different color if they appear more than once in access.

    Can anyone assist me with my statement.
     
  2. 2006/02/14
    llkhoutx

    llkhoutx Inactive

    Joined:
    2006/02/14
    Messages:
    1
    Likes Received:
    0
    If you're displaying the SSNs on a form, use the Conditional Formating to test a function which return True or False, based on the existence of duplicates. Change the back color of the control using the menu Format|Confitional Formatting.

    The menu Format|Conditional Formatting expression is fCheck4Duplicates[SSN], being either True or False. Set the color at your discretion.

    The class module function is a DAO/ADO instruction sequence checking for counting duplicate SSNs, e.g.

    public function fCheck4Duplicates(sSSN as string) as boolean
    dim db as dao.database
    dim rs as dao.record
    dim strSQL as string
    fChech4Duplicates=False
    set db=currentdb
    'returns count of SSN if gt 1
    strSQL= "SELECT SSN, Count(SSN) AS NumberOfSSN FROM YourTableName GROUP BY SSN HAVING SSN =" & CHR(34) & sSSN & chr(34) & " AND NumberOfSSN >" & 1
    set rs=db.openrecordset(strSQL,dbopensnapshot)
    'no records
    if rs.eof and rs.bof then goto Exit_Exit
    'a record exists, count has to be > 1
    fChech4Duplicates=True
    rs.close
    db.close
    set rs=nothing
    set db=nothing
    end function

    I'm not guaranteeing that this is going to be extremely fast because each row has to be checked. Furthermore, you may experience some screen flicker with a large number of rows while the calculations are being permormed. Mousing over the form stops the screen flicker.
     

  3. to hide this advert.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.