Results 1 to 4 of 4
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Calling a function from another function

    How to call a function from another function

    I want to put a code in the OnOpen event of an order, that will be
    Triggered only in connection of the function Ftransform.
    The function Ftransform is put in the onClick event in the control
    Of a form.
    For example I have a small function called InvisibleInvoice.
    I want this function to be in the OnOpen event of the report
    And to come into force only when the function Ftransform works.
    So to repeat, how to put the function Invsibibled Invoice and to refer
    To the function Ftransform? Just to explain the function Ftransofrm is opening the report under special conditions.
    I will be grateful to any advice

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Calling a function from another function

    I think you need to explain a bit more. And please include the version of Access you're working with. Some answers only apply to particular versions.

    First of all, anything you put in the OnOpen event is going to execute when that event triggers. The only way you can NOT execute something in that event is if you wrap it in a conditional statement that checks to see if some condition is met and, if so, calls the function you want to call.

    Under normal circumstances, if you use the result of your FTransform function as the condition, that would give you what you want.
    <pre>If FTransform=Whatever Then
    InvisibleInvoice
    End If</pre>

    Notice I said "normal". You appear to be asking how to use the result of a function that opens a report in the report it just opened. And you want to do it in the OnOpen event of that report! That means that you CAN'T refer to the FTransform function within the report that is opened because it will try to open it again each time you call it. And since you want to call it from the OnOpen event, you're going to have an ugly combination of an endless loop and a million error messages.

    Maybe if you explain more specifically what you're trying to accomplish and what your functions do and whether they are in the report, on a form or in a public module, someone can help you.
    Charlotte

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Posts
    254
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Calling a function from another function

    Thank you very much for your precious advices.I want to express my appreciation of this site since it is niot the first time that i receive very kind and very clever suggestions.
    I want to be a bit more clear with ehat I want to do in order to help me find my mistakes.I want to open a report with a function, and on opening the report I want that
    some actions to be executed with another function.Obviously the first function should be declared as Boolean like
    ==============================
    Public Function f1(args) As Boolean
    DoCmd.OpenReport "R1", acViewPreview
    End Function
    ===========================
    This function is triggered by the onclick event of a control on a form like this
    ======================
    Private Sub Command472_Click()
    F1 (args)
    End Sub
    ============================
    I want to use another function, which for sake of clarity I have simplified like this
    =========================
    Public Function beepit()
    DoCmd.Beep
    End Function
    ==========================
    And I want this function to be used in the OnOpen event of a report only when the function f1(args)is used, like this:
    =============================
    Private Sub Report_Open(Cancel As Integer)
    If Fc1(args) = True Then
    Beepit
    End If
    End Sub
    ==========================
    A very elegant solution but I doesn

  4. #4
    New Lounger
    Join Date
    Dec 2000
    Location
    Rockhampton, Queensland, Australia
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Calling a function from another function

    Public Function f1(args) As Boolean

    if args=whatever then
    f1=true
    else
    f1=false
    endif

    End Function
    ===========================
    This function is triggered by the onclick event of a control on a form like this
    ======================
    Private Sub Command472_Click()
    DoCmd.OpenReport "R1", acViewPreview
    End Sub
    ============================

    Public Function beepit()
    DoCmd.Beep
    End Function
    ==========================

    Private Sub Report_Open(Cancel As Integer)
    If F1(args) Then
    Beepit
    End If
    End Sub
    ==========================

Posting Permissions

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