Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004
    Posts
    77

    Unanswered: How to write a correct expression for this control!

    Hi there

    I have written this code that I think can help me solve my problem(big nightmare) , can anyone have a second look pls to confirm it makes sense and if so how can I write a correction expression on my control (total ) to get it to work as it should.



    Public Function total(AmountinPounds As Currency) As Currency
    Dim commamount As Currency
    Dim total As Currency
    Dim AmountinPounds As Currency
    If commamount >= 2000 Then
    total = AmountinPounds * 0.3
    Else
    total = AmountinPounds + commamount
    End If
    End Function

    Many Thanks for ur help in advance.

  2. #2
    Join Date
    Apr 2003
    Location
    Alabama, USA
    Posts
    154
    What are you trying to accomplish? AS you have it right now you code does this;

    Just translating your simple IF statement into plain english give this;
    If commaamount is greater than or equal to 2000 then
    total = AmountinPounds * 0.3
    For any other case
    total = AmountinPounds + commamount

    Where does the function get the value for commaamount? Should that now also be passed to the function?

    Public Function total(AmountinPounds As Currency, commaamount as Currency) As Currency

    Maybe more explanation on what you are trying to accomplish would ched more light on any problems you are having?
    http://AccessDB.Info

    You live and learn. At any rate, you live. - Douglas Adams

  3. #3
    Join Date
    Apr 2004
    Posts
    77

    Unhappy How to write a correct expression for this control!

    Hi there

    Many Thanks for ur reply.

    this is what I am trying to do.....I have a text box (pounds) the user keys this in) textbox (exchangerate) users keys this in also another text boxt?(naira) which has (pounds * exchangerate) on it to get that amount.

    there is a commamount (really a commission) charged which is its own text box and the amount is keyed in by users also ....this commamount + pounds gives total amount.

    now if the pound is >=2000 this should be times by 0.3 to give me the commamout.

    I have tried everything I can do to get this to work so now I think if only the text box totalamount can have an expression that handles the 0.3 and

    the + together, my solution would be easier.

    hence my code ....vba I have little understanding and so I am struggling very much .


    a further breakdown
    I have the ff fields to work as :

    I have for (A) amtinST , (B) exchangerate, (C) amtinNa . [A*B=C] :-1 then

    a comm is charge on the (A) amtinST (ComAmt)

    and then a totaamountl (E) is calculated as (A+the commAmt).

    if >=2000 *0.3. (so if 2000) is keyed in the text box I want to be able to* by 0.3 if not just add my commamount to the pounds to give me the total.

    I need to get a correct code and expression to put on the total text box.


    Many Many Thanks for ur reply, .

Posting Permissions

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