Results 1 to 4 of 4
  1. #1
    JayRab is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2013
    Posts
    78

    Verifying Not a Duplicate in table before Allowing SaveRecord in Form for that Table

    For Example I have a piece of equipment with ID 8060. I have a form were they enter a maintenance request for 8060 and I want to check to make sure there isnt an Active/Open request already in the Table for 8060. I can have the equipment 8060 on the table numerous times with a Status of "Closed" but I only want 1 instance of 8060 with status of "Active/Open".



    I tried an If statement with DCount() placed on AfterUpdate event procedure for the drop box to select the equipment. The Status is Automatically set to Active/Open on Form load. So if I select 8060 from my drop box, I want a messagebox to popup saying duplicate already exists or whatever.

    If DCount("*","[Equipment Downtime]","Equipment='&me.Equipment&' and Status ='&me.Status&'")>0 then
    MsgBox "There is already an Active Maintenance Request for this Equipment. Please Close existing Request before logging another!"
    Cancel=true
    end if

    I get nothing when I run this code. No errors no stop no nothing.

    thanks for any help.

  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,521
    The syntax is off:

    DLookup Usage Samples
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    JayRab is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Oct 2013
    Posts
    78
    Awesome thanks for the quick reply. Syntax has been my enemy here lately.

    If DCount("*", "[Equipment Downtime]", "Equipment='" & Forms![Equipment DownTime]!Equipment & "' AND Status = '" & Forms![Equipment DownTime]!Status & "'") > 0 Then

    that got it fixed.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help. It seems like Greek until one day it all falls into place and it seems easy. Welcome to the site by the way!
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Table allowing duplicate primary keys
    By Count Duckula in forum Access
    Replies: 4
    Last Post: 06-13-2013, 09:12 AM
  2. Replies: 1
    Last Post: 03-04-2013, 08:09 PM
  3. Replies: 5
    Last Post: 05-02-2012, 07:56 AM
  4. Verifying duplicate invoice numbers?
    By swaninwa in forum Access
    Replies: 1
    Last Post: 03-27-2012, 04:34 PM
  5. Replies: 0
    Last Post: 01-06-2009, 02:17 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