Odd .Repaint behavior

K

KurtW

Hi there. I have an Access 2003 form with a few subforms. 1 subform shows
line items (and a count of same).

The counter on my subform updates just fine as long as there is at least one
record to count. If the subform returns no records, the counter does not seem
to update. BUT, if you scroll down the page and back up, the counter WILL
empty as it should. So I definitely think this is some sort of .Repaint
glitch.

I have all of the code on the main form to guarntee that there will always
be an Form_Current event to work with. All debugs fire, so I know that the
code is being executed. But the subform will not repaint if it has 0 records
unless you force it by scrolling off and then back on to that section of
screen. Here are the sub calls (in the main form):

Hi there. I have an Access 2003 form with a few subforms. 1 subform shows
line items (and a count of same).

The counter on my subform updates just fine as long as there is at least one
record to count. If the subform returns no records, the counter does not seem
to update. BUT, if you scroll down the page and back up, the counter WILL
empty as it should. So I definitely think this is some sort of .Repaint
glitch.

I have all of the code on the main form to guarntee that there will always
be an Form_Current event to work with. All debugs fire, so I know that the
code is being executed. But the subform will not repaint if it has 0 records
unless you force it by scrolling off and then back on to that section of
screen. Here are the sub calls (in the main form):

'-------------------------
' Form_Current()
'-------------------------
Private Sub Form_Current()
'----- Call sub to clear current order details count.
Call subClearCounter
'----- Call the sub to set order details count.
Call subSetCounter
End Sub

And here are the subs:

'--------------------
' subClearCounter()
'--------------------
Private Sub subClearCounter()
Me.sbfrmShippersOrderDetail.Form.txtCounter.Value = ""
Me.sbfrmShippersOrderDetail.Form.Repaint
End Sub

'---------------------
' subSetCounter()
'--------------------
Private Sub subSetCounter()
'----- Clear any old counter data.
Me.sbfrmShippersOrderDetail.Form.txtCounter.Value = ""
Me.sbfrmShippersOrderDetail.Form.Repaint

strSQL = "SELECT OrderDetailID FROM tblOrderDetail " & _
"WHERE ShipmentNumber = " & CLng(Me.txtShipmentNumber.Value) & " ;"

Set oConn = CurrentProject.AccessConnection

If rsTemp.State = adStateOpen Then rsTemp.Close

With rsTemp
..ActiveConnection = oConn
..CursorLocation = adUseClient
..CursorType = adOpenForwardOnly
..LockType = adLockReadOnly
..Open strSQL
End With

If rsTemp.EOF Then
Me.sbfrmShippersOrderDetail.Form.txtCounter.Value = ""
Me.sbfrmShippersOrderDetail.Form.Repaint

If rsTemp.State = adStateOpen Then rsTemp.Close
Else
Me.sbfrmShippersOrderDetail.Form.txtCounter.Value = CStr(rsTemp.RecordCount)
& " order line items."
Me.sbfrmShippersOrderDetail.Form.Repaint
rsTemp.Close
End If

Me.sbfrmShippersOrderDetail.Form.Repaint
End Sub

Does anyone know what might be interfering with the repaint?

Thanks
 
Top