How to check data entered into a form is accurate with data in a table?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kenny24
    New Member
    • Dec 2011
    • 3

    How to check data entered into a form is accurate with data in a table?

    I have a form (Form A), where I require the user to enter a CustomerID which they have created using a separate form (Form B) and which the data is stored in (Table B).

    How would I go about checking the CustomerID they enter into Form A is an exact match to one of the CustomerID's stored in Table B?

    I guess I'm struggling with finding the code to cross-reference between sources of data.

    Any help or advise would be greatly appreciated.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32633

    #2
    Instead of allowing them to type the data in, why not provide a ComboBox which is populated with the valid entries from the other table?

    Comment

    • Kenny24
      New Member
      • Dec 2011
      • 3

      #3
      That's one option.

      How would I ensure that CustomerID's that have already made choices over what products they wish to purchase (and therefore, have their details stored in a separate table) are not present in the combo box?

      To rephrase, I only want CustomerID's that haven't made their purchase choices available for picking.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32633

        #4
        You simply ensure the ComboBox is populated by those items which fit your criteria.

        Something like :

        Code:
        SELECT tC.CustomerID
             , tC.CustomerName
        FROM   [tblCustomer] AS [tC]
               LEFT JOIN
               [tblPurchase] AS [tP]
          ON   tC.CustomerID = tP.CustomerID
        WHERE  (tP.CustomerID Is Null)

        Comment

        Working...