Results 1 to 2 of 2

Thread: Lookup value

  1. #1
    Join Date
    Mar 2006
    Posts
    42

    Unanswered: Lookup value

    In my form i want to lookup a field in the query and multiply this to the value of a control.I get however errors.is it possible to do what i am doing :

    Dim NewUnitprice As Double
    set NewUnitPrice = " CCur(Nz(DLookUp("NewUnitPrice";"qryAmount";"OrderI D=" & [Orders].[OrderID]);0))"

    Me!extendedprice = NewUnitprice

    Where is the error in my code ?
    Thank you in advance

  2. #2
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    several near-misses, several errors, one (to my taste!!) misguided following of Micro$oft example code! have you deliberately set this up to see if anyone is still awake??

    probably
    Me.extendedprice = CCur(Nz(DLookUp("NewUnitPrice", "qryAmount", "OrderID=" & [Orders].[OrderID]),0))
    is closer to where you want to be.

    why?
    not an easy answer!
    M$ is hugely inconsistent!!

    set - only with objects, not with controls (which is confusing since controls are objects!!), certainly not for non-object variables such as your double.

    "blah blah" - everything inside the quotes is a literal string: no way your literal string makes a comfortable double

    NewUnitPrice As Double = ccur(<anything>) does not make 100% sense since ccur() returns a scaled longinteger which will fit into a double but it will be uncomfortable (and pointless!) there.

    ...and although the M$ examples typically use me!thisControl my preference is me.thisControl since
    a/ it provokes the 'intelliprompt' helper.
    b/ it makes more sense, because:
    ! is supposed to be used in:
    collection!item
    . is supposed to be used in
    object.property
    my digestion works better when a form is an object rather than a collection (the form-object contains a collection of controls but is not itself a collection). maybe the originally intended syntax was something like form.controls!thisControl.property = Xxx

    izy
    currently using SS 2008R2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •