Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Jul 2006
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    How ironic is this Thread Title??? . . . this posting may be a duplicate because I don't think it went through the first time . . .

    My question is how to avoid having information in a field. I'll try to explain it better in this post.

    If I have a company called Applied International Training, I will use the code AIT. But later in my database I come across another company called Advance Internal Technology, I would most likely try to use AIT for that company as well. How can I get my table to know that I've already used AIT and prompt me that I cannot use it again, that I have to choose another ID code?

  2. #2
    5 Star Lounger AndrewKKWalker's Avatar
    Join Date
    Apr 2001
    Location
    Cambridge, UK
    Posts
    1,020
    Thanks
    0
    Thanked 3 Times in 3 Posts
    Are you using Access or SQL Server for the data?

    If SQL Server you could use a TRIGGER to check

    For Access you would need to write some code behind the Before Update Event of the field,
    but this is only possible at Form Data entry level, NOT Table data entry.

    Can you provide a bit more info as to where the possible duplicate is being entered from.
    Andrew

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    You can also create a unique index on the field that holds the company codes. This will prevent you using the same code twice, but will give you a rather 'unfriendly' error message if you try.
    Andrew's method of using the Before Update event of a form, allows you to write your own message, and so create something more helpful.
    Regards
    John



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •