Entering data in 3 ways

  • Thread starter Birgit via AccessMonster.com
  • Start date
B

Birgit via AccessMonster.com

Hi!
I have been bilding a form for orders (frmOrders) including a subform for
order detais (frmRows). In the frmRows is a control for UnitPrice. I should
be able to enter data into it in 3 ways:

1. Directly from table Products.
2. Based on calculation square meter*m2Price.
3. Manually.

Placing a sentence =IIf(m2Price>0;m2Price;ProdPrice) into the UnitPrice
control works in cases 1 and 2 but entering data manually does not.

Now I have solved this problem by macro: doubleClicking on control UnitPrice
copies the value from m2Price and I can edit the UnitPrice control. I know
there must be more sophisticated way to do this, but I don't know how. Is
possible to do this event procedure OnEnter? I have tried that with the macro
but it fires a circulation. Does it work by VBA code and how it should be
written, can anyone help me? Thanks for advance!
 
M

Marshall Barton

Birgit said:
I have been bilding a form for orders (frmOrders) including a subform for
order detais (frmRows). In the frmRows is a control for UnitPrice. I should
be able to enter data into it in 3 ways:

1. Directly from table Products.
2. Based on calculation square meter*m2Price.
3. Manually.

Placing a sentence =IIf(m2Price>0;m2Price;ProdPrice) into the UnitPrice
control works in cases 1 and 2 but entering data manually does not.

Now I have solved this problem by macro: doubleClicking on control UnitPrice
copies the value from m2Price and I can edit the UnitPrice control. I know
there must be more sophisticated way to do this, but I don't know how. Is
possible to do this event procedure OnEnter? I have tried that with the macro
but it fires a circulation. Does it work by VBA code and how it should be
written, can anyone help me?


The VBA code to do that could be:

If m2Price>0 Then
UnitPrice = m2Price
Else
UnitPrice = ProdPrice
End If

But the questions are where and when to do that.

You can not use the unit price text box's DefaultValue
property because the product must be selected before the
price can be determined and the default value is applied on
the data entry action. If the m2price and product price can
be determined immediately at the time the product is
selected, then you probably can put the code in the product
combo(?) box's AfterUpdate event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top