Multi-Line Conversion

  • Thread starter Thread starter Albert
  • Start date Start date
A

Albert

Hello,
I have a form with four fields: Name; CurrencyRate; txtAmount; txtConversion
I am displaying a list of foreign currencies in continuous form mode (saved
in tblCurrency).

I would like to have the user be able to enter a number into txtAmount and
get a conversion in U.S. dollars in txtConversion by using (CurrencyRate *
txtAmount) and have the form keep that amount until a new one is entered. I
would like to trigger the calculation from the AfterUpdate event on
txtAmount

Example
EUR 1.3 10 $13.00
JPY .8 15 $12.00

My problem is that in continuous form mode, all the lines are changing to
the new amount.

Example:
EUR 1.3 10 $13.00
JPY .8 10 $13.00

Any help would be appreciated!

Here is the code so far:

Private Sub txtAmount_AfterUpdate()

Dim strAmount As Double
Dim strConversion As Currency

strAmount = 0
strConversion = 0

strAmount = txtAmount

If strAmount = 0 Then
'do nothing
Else
strConversion = strAmount * Me.Rate
Me.txtConversion = strConversion
End If

End Sub
 
You say that txtAmount and txtConversion are fields, but it sounds as if
they are unbound text boxes. If so, the behavior you have seen is to be
expected. An unbound control in a continuous form will apply to all
records. It will apply to all records in a single form, too, but you have
to scroll through the records to see that.
Are you storing any of this information, or are you using the form as a sort
of calculator?
 
Thanks for the tip. I added a field to the table for txtAmount because it
doesn't really matter if it is stored or not. That solved the problem -
works great now.

Albert
 

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

Back
Top