473,321 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,321 software developers and data experts.

Efficiency issues? Function takes 7-10 seconds to complete/refresh

Knut Ole
I have a function to draw some shapes on a form depending on values in queries/tables. The whole procedure takes up to ten seconds however, and as I'm new to coding, I assume I might have a lot to gain on making my code more efficient...?

Are there any very obvious time-consumers in my code, which can be settled much more efficiently?

Any guidance would be greatly appreciated.



(In the db I have a main form "Calendar," which has 67 subforms (frmSub01-67) in which drawings are made. The "finished product" looks more or less like this:


Expand|Select|Wrap|Line Numbers
  1.  
  2. Public Function makeArrows()
  3.  
  4.     Dim RecSetSortAll As Recordset
  5.     Dim RecSetDatePoint As Recordset
  6.     Dim RecSetRooms As Recordset
  7.  
  8.     Dim ctl As Control
  9.     Dim frmSub As Form
  10.     Dim strSubForm As Form
  11.  
  12.  
  13.     startTime = Time()
  14. '***************************
  15. '''initializing recordsets
  16. '***************************
  17.     'Table!DatePointer.Refresh
  18.    ' Tables!Bookings.Refresh
  19.     'Tables!Contacts.Refresh
  20.     'Queries!qSortAll.Refresh
  21.  
  22.     Set RecSetDatePoint = CurrentDb.OpenRecordset("DatePointer")
  23.     Set RecSetSortAll = CurrentDb.OpenRecordset("qSortAll")
  24.     Set RecSetRooms = CurrentDb.OpenRecordset("qAllRoomsList")
  25.  
  26.  
  27.     'Set rsRoomPoint = CurrentDb.OpenRecordset("qRoomPoint")
  28.     'Set rsTotRooms = CurrentDb.OpenRecordset("Rooms")
  29.  
  30. ''' find rsDatePointer for calendarview start date, formerly variable "c"
  31.     dStart = RecSetDatePoint.Fields("RStartDate").Value
  32.  
  33. ''' find total no of rooms / rows in calendar
  34.     'totRooms = rsTotRooms.RecordCount
  35.     'MsgBox totRooms
  36.  
  37.     'd = 0
  38.     'intNoRooms = RoomPoint
  39.     'str( = "frmSub1"
  40.     'str1 = "frmSub01"
  41.  
  42.  
  43.  
  44. '***************************************************
  45. '''looping thru every subform control to disconnect
  46. '***************************************************
  47.     For Each ctl In Forms!Calendar
  48.  
  49.         If ctl.ControlType = acSubform Then
  50.          If Left(ctl.Name, 3) = "ctr" Then
  51.             'srcObject = Forms!Calendar!(ctl.Name).SourceObject
  52.             'MsgBox ctl.Name
  53.          ''' disconnecting subform from mainform, opening subform
  54.             Forms!Calendar!(ctl.Name).SourceObject = ""
  55.             'Forms!Calendar!(ctl.Name).Height = 400
  56.  
  57.  
  58.  
  59.          End If
  60.         End If
  61.  
  62.     Next ctl
  63. 'MsgBox "disconnected"
  64.  
  65.  
  66.  
  67.  
  68. '******************************************
  69. ''' delete all controls in all subforms ...
  70. '******************************************
  71.         p = 0
  72.  
  73.         Do While p < 67
  74.             p = p + 1
  75.                 If p < 10 Then
  76.                     strForms = "frmSub0" & p
  77.                 Else
  78.                     strForms = "frmSub" & p
  79.                 End If
  80.  
  81.             DoCmd.OpenForm strForms, acDesign, , , acFormEdit, acHidden
  82.  
  83.             Do While Forms(strForms).Controls.Count > 0
  84.                 DeleteControl strForms, Forms(strForms).Controls(0).Name
  85.             Loop
  86.             'With Forms(strForms).Controls
  87.             '     Do While .Count > 0
  88.             '       Call DeleteControl(strForms, .Item(0).Name)
  89.             '     Loop
  90.             'End With
  91.  
  92.  
  93.             DoCmd.Close acForm, strForms, acSaveYes
  94.         Loop
  95.     'MsgBox p & " subforms massacred..."
  96.  
  97.  
  98.  
  99.  
  100.  
  101.  
  102. '*****************************
  103. '  ARROWS LOOP for ALL ROOMS
  104. '*****************************
  105.     q = 0                                                                              'frmSub number count
  106.  
  107.     Do Until RecSetRooms.EOF
  108.  
  109.         '**************************************************
  110.         'drawing room# box for each room (each RecSetRooms)
  111.         '**************************************************
  112.             q = q + 1
  113.                                                                                         '*******************************************
  114.             If q < 10 Then strForms = "frmSub0" & q Else strForms = "frmSub" & q        'determining which form, counting roomlist!!
  115.                                                                                         '*******************************************
  116.             roomNow = RecSetRooms.Fields("RoomNumber").Value
  117.             'MsgBox "drawing room-number " & roomNow & " in " & strForms & "..."
  118.  
  119.             DoCmd.OpenForm strForms, acDesign, , , acFormEdit, acHidden                 'open frmSub for drawing
  120.  
  121.             '*******************
  122.             'DRAW: room-number box
  123.             '*******************
  124.             Set cRoomBox = CreateControl(strForms, acLabel)
  125.                 With cRoomBox
  126.                     .BackStyle = 1
  127.                     .Width = 580
  128.                     .Height = 375
  129.                     .Left = 50
  130.                     .Top = 25
  131.                     .Caption = roomNow
  132.                     .BorderStyle = 1
  133.                     .FontSize = 14
  134.                     .TextAlign = 2
  135.                     .BorderWidth = 1
  136.                     .FontWeight = 700
  137.                     '.BackColor = RGB(0, 255, 0)
  138.                 End With
  139.  
  140.             DoCmd.Close acForm, strForms, acSaveYes                        'close frmSub after drawing
  141.  
  142.             '********
  143.             'end draw
  144.             '********
  145.  
  146.  
  147.  
  148.         '************************************
  149.         'start drawing bookings for this room
  150.         '************************************
  151.  
  152.         If Not RecSetSortAll.EOF Then                                       'make sure still bookings to be drawn, if not, return to room-number loop
  153.  
  154.  
  155.             recordNow = RecSetSortAll.Fields("qBase.RoomNumber").Value      'recordset of bookings
  156.             roomNow = RecSetRooms.Fields("RoomNumber").Value                'list of roomnumbers
  157.             'MsgBox "before if recnow = roomnow, values are " & recordNow & " = " & roomNow
  158.             If recordNow = roomNow Then                                     'there are bookings for this room
  159.             Do Until recordNow <> roomNow
  160.                     'MsgBox "inside loop of recnow <> roomnow, w values " & recordNow & " <> " & roomNow
  161.                     '***************************
  162.                     ' open subform (again), draw
  163.                     '***************************
  164.                                                                                             '*******************************************
  165.                     If q < 10 Then strForms = "frmSub0" & q Else strForms = "frmSub" & q   'determining which form, counting roomlist!!
  166.                                                                                             '*******************************************
  167.                                                                                             '(not really necessary, as q only changes with roomlist)
  168.                     'MsgBox "match! starting drawing in " & strForms & "..."
  169.  
  170.                     DoCmd.OpenForm strForms, acDesign, , , acFormEdit, acHidden   'open frmSub for drawing
  171.  
  172.  
  173.                 '// finding variables
  174.                     slBeg = RecSetSortAll.Fields("SlotBegin").Value
  175.                     slEnd = RecSetSortAll.Fields("SlotEnd").Value
  176.                     rcBookID = RecSetSortAll.Fields("Bookings.ID").Value
  177.                     leftPos = (slBeg - dStart) * 1217 + 850
  178.                     bConf = RecSetSortAll.Fields("Confirmed").Value
  179.                     'MsgBox bConf
  180.                     'widthMsg = ((slEnd - slBeg) * 1217) - 380
  181.                     'MsgBox "starting pos = " & leftPos & ", and width = " & widthMsg
  182.  
  183.  
  184.                 '// TAIL IMAGE
  185.                     Set cImg1 = CreateControl(strForms, acImage)
  186.                         If bConf = True Then
  187.                             With cImg1
  188.                                 .BackStyle = 0
  189.                                 .Width = 432
  190.                                 .SizeMode = 0
  191.                                 .Height = 360
  192.                                 .Left = leftPos
  193.                                 .Top = 30
  194.                                 .ControlTipText = rcBookID
  195.                                 .OnClick = ""
  196.                                 .Picture = "C:\Users\Lailita\Documents\arrows\yellowA.wmf"
  197.                             End With
  198.                         Else
  199.                             With cImg1
  200.                                 .BackStyle = 0
  201.                                 .Width = 432
  202.                                 .SizeMode = 0
  203.                                 .Height = 360
  204.                                 .Left = leftPos
  205.                                 .Top = 30
  206.                                 .ControlTipText = rcBookID
  207.                                 .OnClick = ""
  208.                                 .Picture = "C:\Users\Lailita\Documents\arrows\yshadeA.wmf"
  209.                             End With
  210.                         End If
  211.  
  212.  
  213.  
  214.                     '// HEAD IMAGE
  215.                       Set cImg2 = CreateControl(strForms, acImage)
  216.                         If bConf = True Then
  217.                             With cImg2
  218.                                 .BackStyle = 0
  219.                                 .Width = 432
  220.                                 .Height = 360
  221.                                 .SizeMode = 0
  222.                                 .ControlTipText = rcBookID
  223.                                 .Left = leftPos + ((slEnd - slBeg) * 1217) - 380
  224.                                 '.Left = leftPos + 300
  225.                                 .Top = 30
  226.                                 .Picture = "C:\Users\Lailita\Documents\arrows\yellowAh.wmf"
  227.                             End With
  228.                         Else
  229.                             With cImg2
  230.                                 .BackStyle = 0
  231.                                 .Width = 432
  232.                                 .SizeMode = 0
  233.                                 .Height = 360
  234.                                 .ControlTipText = rcBookID
  235.                                 .Left = leftPos + ((slEnd - slBeg) * 1217) - 380
  236.                                 '.Left = leftPos + 300
  237.                                 .Top = 30
  238.                                 .Picture = "C:\Users\Lailita\Documents\arrows\yshadeAh.wmf"
  239.                             End With
  240.                         End If
  241.  
  242.                      '// Shaded Box
  243.                     Set cImg3 = CreateControl(strForms, acImage)
  244.                     If bConf = False Then
  245.                        With cImg3
  246.                             .BackStyle = 0
  247.                             .Width = ((slEnd - slBeg) * 1217) - 432 - 40
  248.                             .Height = 360
  249.                             .SizeMode = 0
  250.                             .ControlTipText = rcBookID
  251.                             .Left = leftPos + 250
  252.                             '.Left = leftPos + 300
  253.                             .Top = 30
  254.                             .Picture = "C:\Users\Lailita\Documents\arrows\yshadeB.wmf"
  255.                         End With
  256.                     Else
  257.                         With cImg3
  258.                             .BackStyle = 0
  259.                             .Width = ((slEnd - slBeg) * 1217) - 432 - 40
  260.                             .Height = 360
  261.                             .SizeMode = 0
  262.                             .ControlTipText = rcBookID
  263.                             .Left = leftPos + 250
  264.                             '.Left = leftPos + 300
  265.                             .Top = 30
  266.                             .Picture = "C:\Users\Lailita\Documents\arrows\yellowB.wmf"
  267.                         End With
  268.                         'MsgBox widthMsg
  269.                     End If
  270.  
  271.  
  272.                     '// BODY LABEL
  273.                       Set cLbl1 = CreateControl(strForms, acLabel)
  274.                         With cLbl1
  275.                             .Visible = True
  276.                             .BackColor = RGB(255, 194, 14)
  277.                             .ForeColor = RGB(255, 255, 255)
  278.                             .FontWeight = 900
  279.                             .TopMargin = 34
  280.                             .TextAlign = 2
  281.                             .BackStyle = 0
  282.                             .FontWeight = 900
  283.                             .Top = 40
  284.                             .Height = 330
  285.                             .Left = leftPos + 250
  286.                             .Width = ((slEnd - slBeg) * 1217) - 432 - 40
  287.                             '.Width = 200
  288.                             .Caption = rcBookID
  289.                         End With
  290.                      If bConf = False Then
  291.                         With cLbl1
  292.                             .ForeColor = RGB(0, 0, 0)
  293.                         End With
  294.                      End If
  295.  
  296.                     DoCmd.Close acForm, strForms, acSaveYes                        'close frmSub after drawing of booking
  297.  
  298.  
  299.  
  300.                    ' MsgBox "success, moving to next booking..."
  301.  
  302.                     RecSetSortAll.MoveNext                                         'moving to next booking
  303.  
  304.                     If Not RecSetSortAll.EOF Then
  305.                     recordNow = RecSetSortAll.Fields("qBase.RoomNumber").Value     'roomnumber of next booking
  306.                     Else
  307.                         Exit Do
  308.                     End If
  309.  
  310.             Loop
  311.  
  312.             Else
  313.                'MsgBox "no more bookings for this room, moving on to next room.."
  314.                ' RecSetSortAll.MoveNext
  315.             End If
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.         Else    'RecSetSortAll.EOF If..Then
  323.             'MsgBox "recsetsortall.eof"
  324.         End If
  325.         RecSetRooms.MoveNext
  326.  
  327.     Loop       'RecSetRooms.EOF loop
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.      'MsgBox "reconnecting"
  343.  
  344. '*************************************************
  345. '''looping thru every subform control to RECONNECT
  346. '*************************************************
  347.  
  348.     For Each ctl In Forms!Calendar
  349.  
  350.         If ctl.ControlType = acSubform Then
  351.          If Left(ctl.Name, 3) = "ctr" Then
  352.             'srcObject = Forms!Calendar!(ctl.Name).SourceObject
  353.             'MsgBox ctl.Name
  354.          ''' disconnecting subform from mainform, opening subform
  355.             srcOb = "frmSub" & Right(ctl.Name, 2)
  356.             Forms!Calendar!(ctl.Name).SourceObject = srcOb
  357.  
  358.          End If
  359.         End If
  360.  
  361.     Next ctl
  362.  
  363.     'MsgBox "reconnected"
  364.  
  365.     'DoCmd.Requery
  366.     'MsgBox "refreshing"
  367.     Forms!Calendar.Refresh
  368.  
  369.     'MsgBox "refreshed"
  370.  
  371.     endTime = Time()
  372.     elapsedTime = endTime - startTime
  373.  
  374.     MsgBox "that took " & Second(elapsedTime) & " secs."
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416. End Function
  417.  
Attached Images
File Type: jpg Capture.jpg (34.1 KB, 328 views)
Mar 26 '11 #1

✓ answered by Rabbit

Rather than a subform for each room, why not one form with all the rooms?

16 1720
TheSmileyCoder
2,322 Expert Mod 2GB
I haven't looked through your code as its quite lengthy. I will maybe give it a go later.
What I would suggest first is to turn of redrawing while your code runs. Add Docmd.Echo False at the start of your code and Docmd.Echo true at the end.
You should also add an error handler in which you turn the drawing back on, otherwise you will be stuck with an empty screen if an error occurs.
Mar 26 '11 #2
i appreciate that!

it's especially the two segments at line 47-62 and line 73-93, they eat up most of the time consumed. i might have made them rather chunky...
Mar 27 '11 #3
ADezii
8,834 Expert 8TB
It appears to me that the long processing time has nothing to do with the efficiency of the Code, but rather with the nature of the Task. Among other things, you are dynamically Deleting/Creating Controls on none less than 67 Sub-Forms, a tall order in and of itself. There are a few items that I noticed which may provide small gains in processing time:
  1. Always explicitly refer to the Object type Libraries to which Objects belong.
    Expand|Select|Wrap|Line Numbers
    1. Dim RecSetSortAll As DAO.Recordset 
    2. Dim RecSetRooms As DAO.Recordset
    3.  
  2. If you are only moving Forward within a Recordset, make it a Forward Only Type Recordset:
    Expand|Select|Wrap|Line Numbers
    1. Set RecSetSortAll = CurrentDb.OpenRecordset("qSortAll", dbOpenSnapshot, dbOpenForwardOnly)
    2. Set RecSetRooms = CurrentDb.OpenRecordset("qAllRoomsList", ", dbOpenSnapshot, dbOpenForwardOnly)
    3.  
  3. Not sure if it is worth it to create a Recordset for a Single Field Lookup, try a DLookup() instead:
    Expand|Select|Wrap|Line Numbers
    1. dStart = DLookup("[RStartDate]", "DatePointer")
    2.           'instead of
    3. Dim RecSetDatePoint As Recordset
    4. Set RecSetDatePoint = CurrentDb.OpenRecordset("DatePointer")
    5. dStart = RecSetDatePoint.Fields("RStartDate").Value  
    6.  
  4. I see no Clean Up chores being performed, namely:
    Expand|Select|Wrap|Line Numbers
    1. RecSetSortAll.Cose 
    2. RecSetRooms.Close
    3. Set RecSetSortAll = Nothing 
    4. Set RecSetRooms = Nothing
  5. I didn’t have much time to look over the Code thoroughly, so if I am incorrect in any of my assumptions, please forgive me.
Mar 27 '11 #4
Rabbit
12,516 Expert Mod 8TB
Rather than a subform for each room, why not one form with all the rooms?
Mar 28 '11 #5
thanks all,


rabbit: would that save me a lot?
Mar 28 '11 #6
TheSmileyCoder
2,322 Expert Mod 2GB
I have some code that will at least help you to isolate which parts take the most time. The code should be placed in a class module.
At the bottom of teh module is an example of how to use it.
Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3. Option Base 1
  4.  
  5. '***********  Class variables  ****************
  6. Private lngStart As Long
  7. Private lngLastEvent As Long
  8. Private strEvent() As String
  9. Private strLog As String
  10. 'Reference function
  11. Private Declare Function GetTickCount Lib "kernel32" () As Long
  12.  
  13.  
  14.  
  15. Public Sub StartTimer()
  16.     lngStart = GetTickCount
  17.     lngLastEvent = lngStart
  18.     ReDim strEvent(2, 1)
  19.     strEvent(1, UBound(strEvent, 2)) = "Timer Started"
  20.     strEvent(2, UBound(strEvent, 2)) = EndTimer
  21. End Sub
  22.  
  23. Public Function addEvent(strInput As String, Optional bFromStart As Boolean = False)
  24.     strLog = strLog & strInput
  25.  
  26.  
  27.     ReDim Preserve strEvent(2, UBound(strEvent, 2) + 1)
  28.     strEvent(1, UBound(strEvent, 2)) = strInput
  29.     strEvent(2, UBound(strEvent, 2)) = EndTimer(bFromStart)
  30.     lngLastEvent = GetTickCount
  31. End Function
  32.  
  33. Public Function toString() As String
  34.     Dim intI As Integer
  35.     Dim lngSpacesEvent As Long
  36.     Dim lngSpacesTime  As Long
  37.     lngSpacesEvent = maxLen(strEvent(), 1)
  38.     lngSpacesTime = maxLen(strEvent(), 2)
  39.  
  40.     For intI = 1 To UBound(strEvent, 2)
  41.         toString = toString & addSpaces(strEvent(1, intI), lngSpacesEvent) & " : " & addSpaces(strEvent(2, intI), lngSpacesTime, False) & vbNewLine
  42.  
  43.     Next
  44. End Function
  45.  
  46. Public Function EndTimer(Optional bFromStart As Boolean = False) As String
  47.     Dim EndTime As Long
  48.     If bFromStart Then
  49.         EndTime = (GetTickCount - lngStart)
  50.     Else
  51.         EndTime = (GetTickCount - lngLastEvent)
  52.     End If
  53.  
  54.  
  55.     Dim s As Integer
  56.     s = EndTime / 1000
  57.     Dim ms As Integer
  58.     ms = EndTime Mod 1000
  59.     If s > 1 Then
  60.         EndTimer = s & "s, " & ms & "ms"
  61.     Else
  62.         EndTimer = ms & "ms"
  63.     End If
  64.  
  65. End Function
  66.  
  67.  
  68. Private Function maxLen(myArray() As String, intCol As Integer)
  69.     Dim lngMax As Long
  70.     Dim intI As Integer
  71.     For intI = 1 To UBound(myArray, 2)
  72.         If Len(myArray(intCol, intI)) > lngMax Then
  73.             lngMax = Len(myArray(intCol, intI))
  74.         End If
  75.     Next
  76.     maxLen = lngMax
  77. End Function
  78. Private Function addSpaces(strInput As String, lngLength As Long, Optional bAfter As Boolean = True) As String
  79.     'Add spaces
  80.     If bAfter Then
  81.         Do While Len(strInput) < lngLength
  82.             strInput = strInput & " "
  83.         Loop
  84.     Else
  85.         Do While Len(strInput) < lngLength
  86.             strInput = " " & strInput
  87.         Loop
  88.     End If
  89.     addSpaces = strInput
  90. End Function
  91.  
  92.  
  93.  
  94. ' ***********  Example usage  ****************
  95.  
  96.  
  97. 'Public Sub testSW()
  98. '    Dim mySW As New TSCWatch
  99. '
  100. '    mySW.StartTimer
  101. '
  102. '    'Run code here
  103. '
  104. '    mySW.addEvent "Code 1 finished"
  105. '
  106. '
  107. '    'Run more code here
  108. '
  109. '    mySW.addEvent "Code 2 finished"
  110. '
  111. '    'Run code here
  112. '
  113. '    mySW.addEvent "Total Time", True
  114. '
  115. '    Debug.Print mySW.toString
  116. '
  117. '    'Cleanup
  118. '        Set mySW = Nothing
  119. 'End Sub
  120.  

Example output:
Expand|Select|Wrap|Line Numbers
  1. Timer Started  :       0ms
  2. First Code bit :     657ms
  3. 2nd code bit   :  2s, 31ms
  4. Total Time     : 3s, 688ms
  5.  
Mar 28 '11 #7
thanks a lot, smiley..
what takes time, apparently, is the clearing of 67 subforms (line 69), and drawing arrows (line 103).

i had the subforms opened/closed for each, while i have now made it so they open all on first use, then not open/closed again before all are closed at end. this saved me approx. 2-3 seconds in average.

im still at 5 seconds average (4.6 - 6.9, mostly at 4.6). however, there are few drawings on the calendar atm, compared to a full one - which could set me back many seconds. in other words, still very short of acceptable levels.

rewriting the whole thing to one subform is a formidable job. can anyone confirm this would give substantial gains? anyone with more concrete information as to exactly which lines are responsible for the time consumed?

the code is in a "module," by the way. any reason it should be in a "class module" or embedded in the calendar form instead?

thank you so much again!
Mar 28 '11 #8
TheSmileyCoder
2,322 Expert Mod 2GB
Hi Knut

I dont think you would gain anything noticeable by placing the code in the calender form. Class modules are something else entirely. (My listed watch for instance is a class).

Im sorry to tell you, but if you have used the listed approaches by ADezii and the DoCmd.Echo False I mentioned, then I dont think there is much more to be gained, since both deleting and creating controls takes some time.

Why have you choosen the approach of 67 subforms? What reasoning is behind the choice?
Mar 28 '11 #9
ok, thanks smiley.
the reason for subforms is first of all it seems orderly. it makes for no relative position information for the drawings, as the subform position on the mainform takes care of that.

another reason, discovered later, is that it's not easy to draw things perfectly in access - the pixels/cm/twips are not perfectly aligned, so i get some drawings being one pixel off. (seems insignificant, but creates some major off-positions in calendar).

so, im not looking forward to making all drawing positions completely relative to the whole thing - though if anyone has a clear-cut way of approaching this, i'd be very glad for some input. im thinking i'd have to create some off-set position constants to use with each drawing? im just afraid i'll never get it accurate due to the problems of twips/pixels mentioned above.

thank you so much so far,
more input on efficiency greatly appreciated (tho i might be reaching a roof here)
Mar 28 '11 #10
for the record:

using only one subForm in which all arrows are drawn greatly reduces the drawing time. apparently it's the opening and closing of forms that take time.

thanks all,
Mar 29 '11 #11
TheSmileyCoder
2,322 Expert Mod 2GB
Im glad that you got it sorted.

Out of curiosity, how much of an efficiency increase did it give? How long time does your form take to draw now?
Mar 29 '11 #12
i went immediately down to 1.1 s. with one subform.

having added some more draw objects (hor/vert lines etc.), im currently back up at around 2.3-3.4 secs. (it's funny, btw, how the drawing time varies by 50% with the exact same job...?)

thanks a lot for your help!
Mar 30 '11 #13
TheSmileyCoder
2,322 Expert Mod 2GB
Just to make sure, you did use the tip on turning off redrawing (DoCmd.Echo False), until the update is finished?

Especially when drawing you should see a good performance boost on that.
Mar 30 '11 #14
i did, but frankly, with or without echos i get exactly the same results... (intermittently 2.3s and 3.4s...)

perhaps it's because i disconnect the subform and the drawings are done in the background in the first place, and when reconnecting subform to mainform, all the new changes are there already... so the drawing process is not visible to the user in the first place.

last question, btw, you know the right code for refreshing/requiering and especially for the code for the "refresh all" button, so that all tables, queries are refreshed before my code runs? it's not really updated every time i make a change in my user-end inferface, and i have to sometimes manually "refresh all..."

thanks again!
Mar 30 '11 #15
TheSmileyCoder
2,322 Expert Mod 2GB
Your probably right, that since you open the form in hidden design view, the Echo did no difference.

Your new question should be asked in a separate thread. And I don't know. I have never had any troubles with tables not being refreshed properly.
Mar 30 '11 #16
aight,
thanks smiley!

i will make a new thread... (longer than 40 chars..;)
Mar 30 '11 #17

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Elaine Jackson | last post by:
Suppose one of the arguments of a function f_1 is another function f_2. Can f_1 access the number of arguments taken by f_2? (I'm writing a little script to automate the construction of logical...
6
by: gustav04 | last post by:
hi all i have a question: what is the difference between a c-function and an c++ class method (both do exactly the same thing). lets say, i have a function called print2std() and a class...
2
by: Kamran | last post by:
Hi I have very little experience of C++, nevertheless I have been asked to write a gui using QT/QWT. I know that I should direct the question to the relevant mailing list and I have done that but...
1
by: bluekite2000 | last post by:
Here is the compilable code, along w/ the error #include<iostream> #include<complex> typedef std::complex<float> ComplexSingle; using namespace std; template<typename T> class X { private:...
13
by: Maroon | last post by:
Hi, I want to write a standard java user defined function, like this example:- select db_fun("roll"), roll from student; **db_fun() will work for all tables of the all databse here db_fun is...
3
by: Phil IU Guy | last post by:
I am having 2 issues, both acting very randomly, and for the most part I dont get this message on most computers, but I have had a couple computers get either issue 1, or issue 2. Issue #1: I...
2
by: news | last post by:
I just upgraded to PHP 4.4.2 on my Slackware 10.2 system. And Apache/mySQL/PHP all work great through a browser. No errors. But when I try to run a PHP script through the command line, which I...
5
by: Joyti | last post by:
Hi, Need help in solving issue. I m having one function: int alllowReset(TRAN & tranP) { if( tranP->name == "PQRS" || ... ..
10
by: David Fort | last post by:
Hi, I'm upgrading a VB6 app to VB.net and I'm having a problem with a call to a function provided in a DLL. The function takes the address of a structure which it will fill in with values. I...
0
by: Crystal | last post by:
I have created a small program that prints out an organization chart in PHP using the GD lib's imagecreate, imageline and imagestring functions. Basically, a user selects an employee from a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.