After Update of Listbox

J

JamesJ

I'm using the following code to 'sync' a row selection of a list box
with other control(s) on the same form:

Private Sub ctlList_AfterUpdate()

Dim rst As DAO.Recordset
If Not IsNull(Me.ctlList) Then
Set rst = Me.RecordsetClone

rst.FindFirst "DvdMovieID=" & Me!ctlList

If rst.NoMatch Then
MsgBox "Not found"
Else
Me.Bookmark = rst.Bookmark
End If

Set rst = Nothing
End If

End Sub

Seems when I select a row in the list box the form 'blinks'. That is to say
for
a split second the data disappears and reappears.
Was wondering if there was a way to avoid this 'blinking' with an
alternative
way of accomplishing the task? The code works fine except for that anomaly.

Thanks,
James
 
D

Dirk Goldgar

JamesJ said:
I'm using the following code to 'sync' a row selection of a list box
with other control(s) on the same form:

Private Sub ctlList_AfterUpdate()

Dim rst As DAO.Recordset
If Not IsNull(Me.ctlList) Then
Set rst = Me.RecordsetClone

rst.FindFirst "DvdMovieID=" & Me!ctlList

If rst.NoMatch Then
MsgBox "Not found"
Else
Me.Bookmark = rst.Bookmark
End If

Set rst = Nothing
End If

End Sub

Seems when I select a row in the list box the form 'blinks'. That is to
say for
a split second the data disappears and reappears.
Was wondering if there was a way to avoid this 'blinking' with an
alternative
way of accomplishing the task? The code works fine except for that
anomaly.


In a form using the same technique, I don't observe any "blinking". Is
there any other code that executes as part of the operation, which might be
affecting this? Code in the form's Current event, maybe? Or a Requery that
is executed when the list box gets the focus?
 
J

JamesJ

There actually is a line of code in the Current event but I
remaked it out and the same thing happens. This happens with
all the forms I use this.

James
 
D

Dirk Goldgar

JamesJ said:
There actually is a line of code in the Current event but I
remaked it out and the same thing happens. This happens with
all the forms I use this.


All forms, no matter what their recordsource? Hmm. Is this a split
database with linked tables? If so, does it have a SQL Server back-end, or
is any database type other than Jet (Access)?

Does it matter how far apart the records are in the form's recordset? If
you use the list box to move from one record to the very next record, does
it make any difference?

Do you experience the "blink" just paging through the records on the form,
without using the list box?

Is there an image control displayed on the form?
 
J

JamesJ

This is a split database but the tables are on my local hard drive.
All Jet.
It occurs whether I click on a row or move using the arrow keys.
Seems to be less when I move with the arrow keys but the other field
and an unbound control 'blinks'.

James
 
D

Dirk Goldgar

JamesJ said:
This is a split database but the tables are on my local hard drive.
All Jet.
It occurs whether I click on a row or move using the arrow keys.
Seems to be less when I move with the arrow keys but the other field
and an unbound control 'blinks'.


Just to clarify: does it blink *only* when you use the list box for
navigation? If you use the bult-in navigation buttons, or use
PageUp/PageDown to move from record to record on the form, does it blink
then?
 
J

JamesJ

Yes. I set the Navigation Buttons to yes and it still does it although the
list box wasn't synced with the form.
Nothing seems to happen when I use PageUp/PageDown. The record
number remains the same in the Navigation Button field(or whatever it's
called)

James
 
D

Dirk Goldgar

JamesJ said:
Yes. I set the Navigation Buttons to yes and it still does it although the
list box wasn't synced with the form.

Then it has nothing to do with the list box and the code to synchronize with
it. So either there's other code or a macro influencing things, or there's
something about the form's recordsource or the controls on the form that is
causing the blink. I wonder: does your form's recordsource use VBA
functions? Or do the controlsources of the controls on the form use VBA
function expressions?

What are the form's RecordSource property and the controls' ControlSource
properties?
Nothing seems to happen when I use PageUp/PageDown. The record
number remains the same in the Navigation Button field(or whatever it's
called)

That suggests that the form is either a multi-page form, or it's so big that
PageUp & PageDown jus scroll the form at the current record. Either that,
or you have the focus in some scrollable control (maybe the list box) when
you press them. Anyway, it's not important. If record navigation via the
navigation buttons causes the blink, we've established that the list box is
not at fault.
 
J

JamesJ

The RecordSource for the form is a select statement. The Control Source for
the
control is a field in the table. The other filed that 'blinks is an unbound
text field
that I use to count the number of rows in the list box. It simply has as
it's control source:
=[ctlList].[ListCount].
I've even removed that unbound field and it still did it.
Also, these are tabbed forms in ac 2007.
 
D

Dirk Goldgar

JamesJ said:
The RecordSource for the form is a select statement. The Control Source
for the
control is a field in the table. The other filed that 'blinks is an
unbound text field
that I use to count the number of rows in the list box. It simply has as
it's control source:
=[ctlList].[ListCount].
I've even removed that unbound field and it still did it.
Also, these are tabbed forms in ac 2007.


James, are you willing to send me a copy of this database (preferally cut
down to the bare minimum necessary to show the problem), so I can have a
look at it? Nothing you've told me so far accounts for any unusual
behavior, and I can't tell for sure whether you're seeing something
unexpected or not. If I can look at a copy of your database, with luck I'll
be able to determine for sure that it's misbehaving and also dig deeper to
discover the cause.

If you're willing to send me your database please make send me a cut-down
copy of it, containing only the elements necessary to demonstrate the
problem, compacted and then zipped to less than 1MB in size (preferably much
smaller). I'll have a look at it, time permitting. You can send it to the
address derived by removing NO SPAM and ".invalid" from the reply address of
this message. If that address isn't visible to you, you can get my address
from my web site, which is listed in my sig. Do *not* post my real address
in the newsgroup -- I don't want to be buried in spam and viruses.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top