Results 1 to 5 of 5
  1. #1
    Jen0dorf is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453

    create a unique text string

    Hi

    I created a simple form with a text box for the user to type in a text string.



    I need to compare that text string to the text string in a table and for it to show if it's been used before.

    so I have a field in 39999 records called Mlink. This Mlink field is not unique and is in the format of LL1234

    I want to type this into a text box and then compare that to the Mlink field in my table and for the box to turn green, show a message OK if the entry has not been used before.

    Sounds simple huh?

    cheers

    Ian

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    In the after update event of the textbox, use a DCount() to see if the value exists, and change the color appropriately. Probably want code in the current event too, to catch when the record changes.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    Jen0dorf is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453
    Hi

    just got back from holiday with grandson - exhausted where does a 4 year old get that much energy?

    Anyway took a look at dCount() and google it as well as youtubed and I seem to be hitting a crossroads with no signposts. Some links take me into visual basic, others into mysql and web applications and others into pages and pages of code that I don't understand.

    I gather that I run DCOunt with criteria that it matches my textbox and if a zero total is the result then the value does not exist and I can then display a message box or anyhting I want.

    The theory is great but would really appreciate a link to a tutorial on how to implement this on a local database

    thanks

    Ian

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    Why do you care about the format of the random string of 6 chars?
    If the format has meaning, please describe what it is.

    In general
    User types a string into txtBoxA eg XYRRED

    So to see if it already exists, you could

    Code:
    if DCount("mlink","tablename", "mlink ='" & txtboxA &"'") = 0 then
        this random string does not exist
    else
        this random string already exists
    end if

  5. #5
    Jen0dorf is offline Competent Performer
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    UK
    Posts
    453
    Hi

    The format has no meaning at all.

    When this database was created all family graves were created and linked using a field designated MLink ( Memorial Link)

    However in the 15 or so years it has taken to photograph and record each grave several volunteers have been involved. With one main transcriber into the final tables.

    Problem is that no logical sequence was used ( o I can't see onee) so a1 is followed by a2 but next month they might start at nn1 followed by nn2

    So when adding new unrelated records is it important to ensure that the proposed mlink has not already been used, Hence my wish to have a method of checking.

    This project is I suppose a "bandaid job" as there was never a concrete nomenclature in place.

    There will be very few new records as the graveyard is on;y excepting existing family memebers.

    thanks for the assist

    Ian

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 6
    Last Post: 05-29-2015, 10:21 AM
  2. Replies: 6
    Last Post: 04-14-2015, 02:34 PM
  3. How to create a unique composite value
    By PackerIntl in forum Programming
    Replies: 13
    Last Post: 03-31-2014, 12:59 PM
  4. Dmax to create unique ID
    By Stika in forum Access
    Replies: 4
    Last Post: 12-23-2012, 03:20 PM
  5. Create a unique report
    By top1hat19 in forum Reports
    Replies: 1
    Last Post: 01-31-2011, 12:42 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums