Code copy value into table

Frederique

Registered User.
Local time
Today, 16:25
Joined
Sep 5, 2016
Messages
17
Hey gents,

I'm struggling with a simple formula. I can search values on the fly in excel but access seems to have a way of its own.

I have a Orderform (parent) which displays the conversionrate for the entire order. In a subform i use a reference to this conversion and currency using :
PHP:
=[Forms]![frm_AddSalesOrders]![ConversionRate]

IT shows up just fine in the formview but this value doesn't want to store itself into my salesorderline table.
Other stuff is searched via Dlookup and those values store just fine.

After having read through several threads i understand that you need an afterupdate event. I have successfully done this for comboboxes but this currencyvalue i haven't figured out yet.

I have tried in afterupdate:
PHP:
Me.[ConversionRate] = [Forms]![frm_AddSalesOrders]![ConversionRate]
but to no avail. Ive played around by adding the tablename between Me. and conversionrate

Can someone point me in the right direction how to store that displayed Conversionrate value? I'm probably overthinking this and i bet you guys know a simple solution.
 
Code:
Me.[ConversionRate] = [Forms]![frm_AddSalesOrders]![ConversionRate]

Doesn't look wrong. I think

Code:
Me.[ConversionRate] = Me.Parent.ConversionRate

should work too. In which control's afterupdate do you have this? If you put

Code:
Debug.print  "Conversion Rate = " & [Forms]![frm_AddSalesOrders]![ConversionRate]
[/CODE]

in the code what you see in the Immediate Window.
 
Last edited:
The immediate window shows:

Code:
Conversion Rate = 0,857
Conversion Rate = 0,857
and yes it shows it twice.

The code runs the moment i select a product to order from a combobox. (afterupdate)
then all parameters get filled in using Dlookup. The currencytype and conversionrate are pulled in using both [Form]![frmSalesOrder]![ConversionRate] and [fkCurrencyID]. But these values don't get stored automatically. The rest does.

I just tried your suggestion;

Code:
Me.[ConversionRate] = Me.SalesOrder.ConversionRate

It doesn't work so i'm missing something very obvious

Thanks for your help again Sneuberg
 
My suggestion was

Code:
Me.[ConversionRate] = Me[COLOR="Blue"].Parent[/COLOR].ConversionRate

Parent needs to be literally Parent, not the name of the parent, also sorry but I said this wrong in my last post. I meant to say

Code:
Me.[ConversionRate] = [Forms]![frm_AddSalesOrders]![ConversionRate]

Does NOT look wrong and apparent the reference is correct as you are seeing it in the Immediate window.

Double check the Me.[ConversionRate] part. I don't understand why it wouldn't appear in the textbox. What's the control source of the ConversionRate textbox? It should be the field name and not something like =[Forms]![frm_AddSalesOrders]![ConversionRate]
 
What's the control source of the ConversionRate textbox? It should be the field name and not something like =[Forms]![frm_AddSalesOrders]![ConversionRate]

That did the trick!!! I had the controlsource as that expression.
Forgot to change it when putting the code in VBA.
Works like a charm now. Much better than using ctrl+" everytime.

Many thanks Sneuberg

I should've joined this forum alot sooner instead of trying to find out everything on my own. Pride i guess :rolleyes:
 

Users who are viewing this thread

Back
Top Bottom