Results 1 to 5 of 5
  1. #1
    Stretch2312 is offline Novice
    Windows Vista Access 2003
    Join Date
    Oct 2012
    Posts
    12

    Table Level Validation

    Hi,
    I have a table with multiple fields, for entering machine defects. I want to prevent duplicate data from being entered. There are 3 fields that need to be validated to prevent this



    1 - "Tag Number" (this is a physical tag placed on the machine, once the repair has been completed the tag can be reused)
    2 - "Red/Blue" (there are 2 types of tags we use)
    3 - "Status" (This is the status of the tag ie Completed, Active, Pending Approval)

    I want to be able to prevent duplicate "Active" tags being entered. For Example;

    If there is a record with a "Red" tag, Number "652" that is "Active", I want to prevent users creating another "Red" "652", until it has been "Completed"


    Please help

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    These tag numbers are reused - why? Is tag assigned to specific machine and used only on that machine? Same tag number will have blue and red versions?

    Try setting compound primary key. Do you want only one record in table for each TagNumber/Color pair and the Status value will be changed?

    This means cannot have historical data in this table.

    Otherwise use a related child table of records that document use of these tags. Consider:

    tblMachines
    MachineID (PK)

    tblTags
    TagNumber (PK)
    MachineID (FK)

    tblTagsHistory
    TagNumber (FK)
    Color
    DateAction
    Action (Pending, Active, Completed)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Stretch2312 is offline Novice
    Windows Vista Access 2003
    Join Date
    Oct 2012
    Posts
    12
    a tag can be used on any machine on any line. The tags are red or blue matal disks which and attched to the relevant peices of machinery.

    I need a way to validate that a tag has been "Completed" before it can be reused online.

    So Tag number and colour can be used multiple time (and reported on historically) i only want to restrict "Active" tags

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Okay, then:

    tblMacines
    MachineID (PK)

    tblTags
    TagNumber (PK)

    tblTagsHistory
    TagNumber (FK)
    Color
    MachineNumber (FK)
    DateAction
    Action

    Don't see any way to set up table to manage the limitation on 'Active' status. This will require form. Can probably set up combobox on data entry form so that the 'Active' action would not be available if 'Active' is the last action associated with selected tag. I say 'probably' because never tried to set up combobox RowSource with criteria like that. I might use VBA code to build the combobox RowSource based on tag number and color.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    PMFJI,

    I would agree with June. The validation probably couldn't be done at the table level (maybe with a UDF?). Using VBA, you have more control over the validation process.
    I would think about using the form before update event. Open a recordset and check the status. But I gets trickier... Is there one record where the status gets updated or one record per status, per color, per machine?

    If someone tried to add a new active record for a "Red" tag, Number "652", you would cancel the update and give a message that Red - 652 is currently active.
    Also have to check if there is an active record for "Red" tag, Number "652" and someone was trying to add a record "Pending",,,, shouldn't be able to add it?

    Can you add a record for "Red, 652, Active" if there is not first a record for "Red, 652, Pending"? Must one follow the other?

    Lots of validating to do.... Not so bad if one record and the status gets updated. Lots of checking, if one record per status, color, number.

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

Similar Threads

  1. No lookup fields at table level then what?
    By justgeig in forum Database Design
    Replies: 3
    Last Post: 06-05-2012, 11:29 AM
  2. Validation at form level
    By Kris in forum Forms
    Replies: 1
    Last Post: 06-28-2011, 06:48 AM
  3. Replies: 0
    Last Post: 03-18-2011, 06:38 AM
  4. BUG! Field level date validation
    By buj in forum Forms
    Replies: 0
    Last Post: 09-16-2010, 08:23 PM
  5. Field Level Date validation
    By fadone in forum Forms
    Replies: 1
    Last Post: 12-09-2005, 10:23 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