Results 1 to 7 of 7
  1. #1
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Flickering Textboxes (A2K)

    I've created a small database for my son's collectible gaming figures. On the data entry form, I have a text box that displays the total number of figures in the database by using a DSum function tied to the Quantity field of the associated table. Whenever the quantity for a particular record is changed, the text box presents a revised quantity...that works well. However, when I scroll through the database records using the navigation buttons on the form, the value in the text box blanks out momentarily as the value is being refreshed/recalculated. The same thing happens to a text box that presents the current date using the =Now() function. Is there a way to get rid of this 'flickering' affect? Thanks for your help.

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

    Re: Flickering Textboxes (A2K)

    It's usually a good idea to put controls like the total in the form header or footer rather than in the detail section, since they are going to recalculate every time you change records otherwise. You can trigger a recalculation from the AfterUpdate event of the form, which should keep it in sync. Aggregate functions like DSum are fairly slow and can be noticeably slow on a slow machine, especially if you are triggering them from the Current event of the form.

    I don't understand the =Now() business. Why would you present the current date in every record? Where did you put that expression?
    Charlotte

  3. #3
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Flickering Textboxes (A2K)

    Thank you, Charlotte. Are you saying that if I put the 'Display the Quantity' text box (the one that's calculated using DSum) in the header or footer, it will not flicker between records? Currently, it's in the Detail section of the form and is updated in the AfterUpdate event of the Quantity field. Will it continue to display the correct quantity if it's in the header or footer?

    Regarding the =Now() business, I have a text box in the Detail section of the form with a Control Source of =Now(). It simply presents the current date in Day, Month Date, Year format. Maybe that should also be in the header or footer section to prevent flickering between records?

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

    Re: Flickering Textboxes (A2K)

    Depending on how your form is set up, a total in the detail of a continuous form doesn't make sense. If you are simply totalling the collection, put it in the header and recalculate it on form open and in the afterupdate event of the control. In the afterupdate event, you simply refer to the control as you have been, but now it's in a different place. If the total is for a group rather than for all records, that's a somewhat different situation.
    Charlotte

  5. #5
    3 Star Lounger
    Join Date
    Mar 2001
    Location
    Frederick, Maryland, USA
    Posts
    296
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Flickering Textboxes (A2K)

    Thanks, Charlotte. I think your guidance will solve the problem. I assume this will work for the Date text box, also?

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

    Re: Flickering Textboxes (A2K)

    If the date text box displays the current date, yes, you should put it in the header or footer too.

  7. #7
    Bronze Lounger
    Join Date
    Nov 2001
    Location
    Arlington, Virginia, USA
    Posts
    1,394
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Re: Flickering Textboxes (A2K)

    <P ID="edit" class=small>(Edited by MarkD on 12-Jan-04 19:28. Corrected bug in code & replaced attachment.)</P>When using calculated controls on a form (especially with sluggish DLookup functions), you can reduce the annoying "flicker" effect by using a label rather than textbox to display the results of the calculation. A label has less overhead than a textbox, and is not prone to "flickering". If interested, see attached demo database. There's two forms, Customers1 & Customers2, based on Northwind.mdb. Each has four unbound textboxes that display the results of a lookup function or other calculation, and four corresponding labels that display the same data. The label captions are updated by form's Current event:

    Private Sub Form_Current()
    UpdateLookupLabels
    End Sub

    Public Sub UpdateLookupLabels()
    With Me
    .lblOrderCount.Caption = Nz(DLookup("OrderCount", "qryCustomerOrderCount", _
    "<!t>[CustomerID]<!/t> ='" & .CustomerID & "'"), "0")
    .lblOrderTotal.Caption = Format$(DLookup("OrderTotals", "qryCustomerOrderTotals", _
    "<!t>[CustomerID]<!/t> ='" & <!t>[CustomerID]<!/t> & "'"), "Currency")

    If .txtOrderCount > 0 Then
    .lblOrderAvg.Caption = Format$(<!t>[txtOrderTotal]<!/t> / <!t>[txtOrderCount]<!/t>, "Currency")
    Else
    .lblOrderAvg.Caption = "$0.00"
    End If

    .lblCurrentDate.Caption = Format$(Now(), "General Date")
    End With
    End Sub

    The two forms are the same, except on the second, the textboxes are in the footer rather than detail section, and the labels that display the data are hidden. The label captions are still updated as shown above - for some reason this seems to eliminate some (but not all) of the textbox flickering. Test both forms to see the difference between textbox & labels. If possible, you can hide the textboxes (or eliminate them altogether) & just update the labels in code. The only issue with using labels for this is, they are not automatically updated the way a textbox is if any of the calculated values changes; you'd have to add extra code to ensure the labels stay current if the calculated data is subject to change.

    Note: Demo db uses linked tables for Northwind data based on default location for Access 2K (C:Program FilesMicrosoft OfficeOfficeSamples) - if necessary use Linked Table Manager to reset links to a different location.

    Edit Note: Found bug when testing in XP that did not occur in A2K if no orders exist for selected Customer - corrected code & replaced attachment.

    HTH
    Attached Files Attached Files

Posting Permissions

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