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?
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?
<<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
I applied the DLookup a littel different and it works.
Thanks
Udik
<<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