Results 1 to 2 of 2
  1. #1
    amsmakkah is offline Novice
    Windows 7 Access 2003
    Join Date
    Mar 2010
    Posts
    2

    Vba dlookup code help!

    i have a form F_Sales and there is a subform F_Sale_subform containing field Item_id. When i type any number in that field if it exist in T_item table it will show description and quantity and price etc.but when i type any number that dooes not exist in items table then it does not show any thing there and go to next blank field and give me very long error of database jet something....



    the thing i want is that when i enter any number in Itemid field it will search it in items table and if it exist it will go on and if not then displays a msgbox that item does not exist and return the focus on itemi_id..

    i think it will be something on exit event code...


    plz help me

  2. #2
    drexasaurus's Avatar
    drexasaurus is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2011
    Location
    Santa Ana, CA
    Posts
    60
    I think the best way to avoid people from entering item ids that are not proper IDs is to use a combo or list box for the id fields that is restricted to only the ids that are already entered into the system. Change the settings so that they cannot enter fields that are not ids in the system.

    If you wanted, you could allow them to enter new ids, but use some event, like before update or whatever would work to check if the id existed in the table, and if not, cancel the update and give a warning to the user, saying that they must enter the ID and product info first before using this ID. Perhaps even open the form for them if they select OK after being asked: "Do you want to open the product information entry form now?"

    You should avoid allowing users to enter bad IDs in the first place. Because of the relationships set in the tables, they will not be allowed to enter a new id unless it is entered into related product table first.

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

Similar Threads

  1. Is DLookUp What I should be using?
    By cameronaziz in forum Forms
    Replies: 2
    Last Post: 03-24-2011, 04:29 PM
  2. Word code in Access - How to modify my current code
    By Alexandre Cote in forum Programming
    Replies: 0
    Last Post: 11-15-2010, 08:26 AM
  3. Code in combobox, code in text box
    By float in forum Forms
    Replies: 3
    Last Post: 09-29-2010, 07:12 AM
  4. DLookup()
    By jgelpi16 in forum Programming
    Replies: 2
    Last Post: 09-15-2010, 07:20 AM
  5. DLookup code not working
    By lukekelly in forum Programming
    Replies: 9
    Last Post: 06-15-2010, 06:08 AM

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