Results 1 to 5 of 5
  1. #1
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    UDF time delay (2003)

    I am College at the moment and teaching my students how to write a simple User Defined Function (three else if's). I was showing how the UDF can be used in a query and also an unbound text box on a form and came across an anomaly that I have never seen before.

    If I have the UDF in a Query and have this query as the control source for the form there is no "time lag" as the result of the UDF displays almost immediately but if I have the UDF in an unbound text box it can take up to 1-2 seconds to refresh and show the result.

    Is there a reason for this a delay?
    Jerry

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

    Re: UDF time delay (2003)

    I don't know the cause, but I generally find that calculated controls on a form are much slower than calculated fields in a query, whether they use user-defined functions or built-in functions such as DLookup. So this might be a good point to teach: where possible, perform calculations in a query.

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: UDF time delay (2003)

    I think you will find that it really takes about the same amount of time regardless of which way you go, but one way give the appearance of being slower. With the function in the query, it probably takes a bit longer to process, but the display is then instantaneous. With the function in the text control, the initial display is quicker, but then it takes longer for the "final" display. This is especially noticable when a continuous form. Generally, I find it better to put the function in the query.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: UDF time delay (2003)

    Thanks Mark and Hans,

    Just for information, the reason I was showing them the two methods as they will be tasked with creating an order entry form very similar to the one in Northwind. If you look at the Orders form there is a text box which calculates the order total by referencing the subform, using =[Orders Subform].Form!OrderSubtotal Even though it is not a UDF, it is totalling the recordset being displayed in the subform. Even though the subform is displaying the recordset dynamically, there is a pronounced delay in the calculations showing through.

    So yes, I have a feeling that the calculations are happening immediately just the form is the delaying factor......so the query is the way forward <img src=/S/grin.gif border=0 alt=grin width=15 height=15>
    Jerry

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

    Re: UDF time delay (2003)

    Subforms are a special case - the interaction between main form and subform is very complicated, events such as the On Current event often fire several times, causing a noticeable delay.

Posting Permissions

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