Evaluate before update

Posted on 2011-10-19
Last Modified: 2012-05-12
In my form frmDesignatedEmployee I have a combo box, data type number, named StoreID from my table tblStore.
I am needing to create new records in my table tblDesignatedEmployee. This table has a field data type number named StoreID. I would like to evaluate BeforeUpdate my combo box to check to make sure that StoreID in my tblDesignatedEmployee has not been already assigned the same StoreID from the Store table. Then inform the user that this store has a designated employee already.
Why? I use an Insert Into query because I need to write four records concurrently.
Question by:Frank Freese
    LVL 119

    Accepted Solution


    place this codes before inserting the records
    If dcount("*","tblDesignatedEmployee","[StoreID]= " & me.StoreID) >0 then
       msgbox "Store ID already exists"
       exit sub
    end if

    you can place the codes in the beforeupdate event of the combo box

    If dcount("*","tblDesignatedEmployee","[StoreID]= " & me.StoreID) >0 then
       msgbox "Store ID already exists"
       exit sub
    end if

    Author Closing Comment

    by:Frank Freese
    thank you - - - perfect

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Join & Write a Comment

    In the article entitled Working with Objects – Part 1 (, you learned the basics of working with objects, properties, methods, and events. In Work…
    I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
    Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
    In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now