Unbound to bound

abcman

Registered User.
Local time
Yesterday, 20:05
Joined
Aug 7, 2010
Messages
18
Hi there,

I made a Dlookup textbox to get a value from a table which is my main price list but need upon filling my form which holds a field called "UnitPrice" to store the value in that field but it does not as it is unbound. Is there away to go around this ? If there is an example it will also assist more.

Appreciate in advance your assistance.
 
I would set the unitPrice to be bound.

Then presumably you have a field that the price refers to e.g. ProductID. I would code the AfterUpdate event for the ProductID field to get the price for the product (using dlookup) and pop it into the unitPrice field.

The code will look something like this:

Code:
Me.unitPrice = DLookup("[Price]", "tblPriceList", "[ProductID]=" & Me.ProductID)

hth
Chris
 
Thanks for the reply, In fact I tried this but still it did not update. I did add the code for the afterupdate in the ProductID and it simply did not update my Unit price field. Any other solutions or is there an example I can look at ?. Thanks.
 
I've attached an example. Take a look at Form1 and change the product to another product. See the price change.

Take a look at the code to see how it works.

hth
Chris
 

Attachments

I would be tempted to combine tblProducts and tblPricelists as this creates a Standard Pricing regime. The variability of prices is on the tblOrdersLines. The combibox for Products could include the Price and assuming the column is 2 (starting with Zero) then:

Code:
Function Orders_ProductAfterUpdate()

    With CodeContextObject
        .[unitPrice] = .[ProductID].Column(2)
    End With

End Function

Simon
 
Stopher thanks for the example but maybe I was not clear. I am trying to fill a form with data. One field I select, upon so another field is been Looked as it gets the value through the Dlookup. I would like both fields to be saved in a table as the one I look for using the Dlookup is not being saved as it is unbound. I am trying to make it bound. Any other example ? Thanks.
 
Stopher thanks for the example but maybe I was not clear. I am trying to fill a form with data. One field I select, upon so another field is been Looked as it gets the value through the Dlookup. I would like both fields to be saved in a table as the one I look for using the Dlookup is not being saved as it is unbound. I am trying to make it bound. Any other example ? Thanks.
The example I provided does exactly that. The product and price fields are both bound. The code simply puts a value in the price field (using a lookup).

hth
Chris
 

Users who are viewing this thread

Back
Top Bottom