Results 1 to 14 of 14
  1. #1
    4 Star Lounger
    Join Date
    May 2003
    Location
    Manchester, Gtr Manchester, England
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts

    button on click (2000)

    Hello I have a function on a form module. This function takes and calculates depedning on inputs on the form. I want to be able to get it to run on the click of a button, by setting the on click event to myfunction(), the desried doesn't happen. It does however calculate when I switch to design and back. How can I get it to play ball.

    Additionally a few of my fields control source are set to equal certain values from other fields, on first opening the form these fields show as "#error#, how can I get around so they don't show anything.

    Finally a few of the fields are percentages though I don't wish to set the type to percentage as it throws my cals out. How can I get the view on the form to display 25% as 25 though the real value is read as 0.25 (this real value is what I wanr?

    Many thanks Darren

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: button on click (2000)

    First question: you can get a command button to execute a function in two different ways:

    1. Enter <code>=MyFunction()</code> in the On Click event in the Properties window. It won't work if you omit the =.

    2. Select [Event Procedure] from the dropdown list in the On Click event. Make the code look like this:

    Private Sub cmdSomething_Click()
    MyFunction
    End Sub

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: button on click (2000)

    Third question: set the Format property to Percentage (and the Decimal Places property to the number of decimals you want to display).

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: button on click (2000)

    Second question: can you tell us more about the control source of the problem text boxes?

  5. #5
    4 Star Lounger
    Join Date
    May 2003
    Location
    Manchester, Gtr Manchester, England
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: button on click (2000)

    Cheers Hans, the project is attached:

    Re Question 1: I have tried as you have guided but still only calcuates when I switch to and back from design?
    Question 2: I have done the percent thing on text commission rate but if I enter say 25 meaning 25%, it shows as 2500" though, whilst I want it show as 25% for the user I still need it to be read by the aplication as 0.25.
    Question 3: The fields clawback amount, clawback factor, unearned months

    Many thanks Darren

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: button on click (2000)

    I don't see an attachment yet...

  7. #7
    4 Star Lounger
    Join Date
    May 2003
    Location
    Manchester, Gtr Manchester, England
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: button on click (2000)

    Blimey!
    Attached Files Attached Files

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: button on click (2000)

    I don't have the faintest idea what the database you attached has to do with the questions you asked. There is no button on the form and no code, there are no controls showing #Error and I don't see a percentage field.

    <img src=/S/confused3.gif border=0 alt=confused3 width=45 height=45>

  9. #9
    4 Star Lounger
    Join Date
    May 2003
    Location
    Manchester, Gtr Manchester, England
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: button on click (2000)

    Ever so sorry, I think I should be getting my head down!
    Take 2.

    Thanks.
    Attached Files Attached Files

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: button on click (2000)

    The command button executes the function, so a value gets calculated, but the result vanishes into thin air because you don't do anything with it. Access is not clairvoyant. You must specify what happens with the result of the calculation. Instead of making it execute the function, I made it recalculate the form.

    To enter a percentage, type for example 4%, including the percent sign.

    You wrote that the control source of the fields that displayed #Error was equal to clawback amount, clawback factor, unearned months. That is not true, the control source consists of calculated expressions. To make them return a blank if one of the contributing factors is blank takes a bit of fiddling with the IsNull and Nz functions.
    Attached Files Attached Files

  11. #11
    4 Star Lounger
    Join Date
    May 2003
    Location
    Manchester, Gtr Manchester, England
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: button on click (2000)

    TVM once again Hans.

    Darren.

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: button on click (2000)

    As usual, I am confused. English is not my native language, so please explain TVM.

  13. #13
    Lounger
    Join Date
    Nov 2001
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: button on click (2000)

    TVM................ ta very much. i.e. Thanks Very Much ????????????? <img src=/S/confused.gif border=0 alt=confused width=15 height=20>

  14. #14
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: button on click (2000)

    Ah, should have recognised that. TVM for the explanation <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

Posting Permissions

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