Results 1 to 3 of 3
  1. #1
    udik is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    6

    check a value on a table

    I have a form "job records" with a label box "offer".


    I would like to make a command button with a code that check if the value of "offer" exist in table "orders" on a field "order no".

    Can some one help with this simple code?

  2. #2
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    If I understand your question, you need something like this:

    <<Quote>>I have a form "job records" with a label box "offer".
    I would like to make a command button with a code that check if the value of "offer" exist in table "orders" on a field "order no".<<Quote>>

    You want the label box to display 'offer exists' or 'no offer'? Create a command button, then display its properties. Go to the Click event, and click on the ellipsis (...) at the end of the line. You should see something like

    CommandButton1_OnClick()
    End sub

    Insert:

    Dim val as variant
    val = DLookup("[tables![Orders]","tables![Orders][orderno]","criteria='offer'")
    If Isnull(val) then
    me![offer].caption="No offer"
    else
    me![offer].caption = "Offer exists"
    end if

    That is just an outline of one way of approaching the problem. I don't know what the name of the command button will be, nor am I sure of the criteria which you are checking. Likewise, it may not be appropriate to just check for null to conclude that no offer exists.
    If you get stuck, repost with the code which you are trying.
    Also, check out this link,
    http://www.techonthenet.com/access/f...in/dlookup.php

  3. #3
    udik is offline Novice
    Windows 7 64bit Access 2003
    Join Date
    Dec 2011
    Posts
    6

    Thanks

    I applied the DLookup a littel different and it works.

    Thanks

    Udik

    Quote Originally Posted by hertfordkc View Post
    <<Quote>>I have a form "job records" with a label box "offer".
    I would like to make a command button with a code that check if the value of "offer" exist in table "orders" on a field "order no".<<Quote>>

    You want the label box to display 'offer exists' or 'no offer'? Create a command button, then display its properties. Go to the Click event, and click on the ellipsis (...) at the end of the line. You should see something like

    CommandButton1_OnClick()
    End sub

    Insert:

    Dim val as variant
    val = DLookup("[tables![Orders]","tables![Orders][orderno]","criteria='offer'")
    If Isnull(val) then
    me![offer].caption="No offer"
    else
    me![offer].caption = "Offer exists"
    end if

    That is just an outline of one way of approaching the problem. I don't know what the name of the command button will be, nor am I sure of the criteria which you are checking. Likewise, it may not be appropriate to just check for null to conclude that no offer exists.
    If you get stuck, repost with the code which you are trying.
    Also, check out this link,http://www.techonthenet.com/access/f...in/dlookup.php

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

Similar Threads

  1. Check to see if record id exists in joined table
    By csoseman in forum Programming
    Replies: 1
    Last Post: 08-18-2011, 01:06 PM
  2. Replies: 1
    Last Post: 08-14-2011, 11:31 PM
  3. how do i check against a table?
    By cheeese in forum Queries
    Replies: 1
    Last Post: 03-19-2011, 11:09 AM
  4. Dynamic Check Boxes values from table
    By ktmjamal in forum Forms
    Replies: 1
    Last Post: 02-21-2011, 07:49 AM
  5. Check if value exist in a table
    By Lucas83 in forum Programming
    Replies: 2
    Last Post: 06-02-2010, 11:42 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