listbox quirk PLEASE HELP

C

Cynthia

I have a command button that opens a form that has an unbound list box.
The query for the list box selects 3 fields from a table no where clause.
Sometimes when we open the form all records appear in the list box, but other
times only a portion of the records in the table appear in the list box?????
I appreciate any help on what my problem could be.
 
M

Marshall Barton

Cynthia said:
I have a command button that opens a form that has an unbound list box.
The query for the list box selects 3 fields from a table no where clause.
Sometimes when we open the form all records appear in the list box, but other
times only a portion of the records in the table appear in the list box?????


You might try adding this to the second form's Load event:

Dim dummy As Long
dummy = Me.[name of listbox].ListCount
 
C

Cynthia

How does setting a variable to the count of the list box help it pull all
items? I had a command button that if I selected I had a stop in the code so
I could read the list count it read as follows.

Dim testid As Long
testid = Me.[name of listbox].ListCount

sometimes it would give me the 1002 record count sometimes it would only
return 700 records when there are 1002 records in my table? I tried out what
you suggested and I got the correct record count twice, but I'm still
skeptical since I was getting the correct answer sometimes before.


Marshall Barton said:
Cynthia said:
I have a command button that opens a form that has an unbound list box.
The query for the list box selects 3 fields from a table no where clause.
Sometimes when we open the form all records appear in the list box, but other
times only a portion of the records in the table appear in the list box?????


You might try adding this to the second form's Load event:

Dim dummy As Long
dummy = Me.[name of listbox].ListCount
 
M

Marshall Barton

All the records must be loaded in ordet to count them. This
is an old, tried and true techique. Unless they changed
something lately, it should work.

I don't see how your button could get the wrong number.
--
Marsh
MVP [MS Access]

How does setting a variable to the count of the list box help it pull all
items? I had a command button that if I selected I had a stop in the code so
I could read the list count it read as follows.

Dim testid As Long
testid = Me.[name of listbox].ListCount

sometimes it would give me the 1002 record count sometimes it would only
return 700 records when there are 1002 records in my table? I tried out what
you suggested and I got the correct record count twice, but I'm still
skeptical since I was getting the correct answer sometimes before.


Marshall Barton said:
Cynthia said:
I have a command button that opens a form that has an unbound list box.
The query for the list box selects 3 fields from a table no where clause.
Sometimes when we open the form all records appear in the list box, but other
times only a portion of the records in the table appear in the list box?????


You might try adding this to the second form's Load event:

Dim dummy As Long
dummy = Me.[name of listbox].ListCount
 
C

Cynthia

What do you mean loaded in order? They are input with a unique id number,
but I am pulling them in order of the circuit field which is a text field. I
dont' see why it doesn't always work either, when the users first complained
I was sure they were wrong until I saw it for myself.

Marshall Barton said:
All the records must be loaded in ordet to count them. This
is an old, tried and true techique. Unless they changed
something lately, it should work.

I don't see how your button could get the wrong number.
--
Marsh
MVP [MS Access]

How does setting a variable to the count of the list box help it pull all
items? I had a command button that if I selected I had a stop in the code so
I could read the list count it read as follows.

Dim testid As Long
testid = Me.[name of listbox].ListCount

sometimes it would give me the 1002 record count sometimes it would only
return 700 records when there are 1002 records in my table? I tried out what
you suggested and I got the correct record count twice, but I'm still
skeptical since I was getting the correct answer sometimes before.


Marshall Barton said:
Cynthia wrote:

I have a command button that opens a form that has an unbound list box.
The query for the list box selects 3 fields from a table no where clause.
Sometimes when we open the form all records appear in the list box, but other
times only a portion of the records in the table appear in the list box?????


You might try adding this to the second form's Load event:

Dim dummy As Long
dummy = Me.[name of listbox].ListCount
 
B

BruceM

I think that means "In order to count the records using this method, the
records must be loaded".

Cynthia said:
What do you mean loaded in order? They are input with a unique id number,
but I am pulling them in order of the circuit field which is a text field.
I
dont' see why it doesn't always work either, when the users first
complained
I was sure they were wrong until I saw it for myself.

Marshall Barton said:
All the records must be loaded in ordet to count them. This
is an old, tried and true techique. Unless they changed
something lately, it should work.

I don't see how your button could get the wrong number.
--
Marsh
MVP [MS Access]

How does setting a variable to the count of the list box help it pull
all
items? I had a command button that if I selected I had a stop in the
code so
I could read the list count it read as follows.

Dim testid As Long
testid = Me.[name of listbox].ListCount

sometimes it would give me the 1002 record count sometimes it would only
return 700 records when there are 1002 records in my table? I tried out
what
you suggested and I got the correct record count twice, but I'm still
skeptical since I was getting the correct answer sometimes before.


:

Cynthia wrote:

I have a command button that opens a form that has an unbound list
box.
The query for the list box selects 3 fields from a table no where
clause.
Sometimes when we open the form all records appear in the list box,
but other
times only a portion of the records in the table appear in the list
box?????


You might try adding this to the second form's Load event:

Dim dummy As Long
dummy = Me.[name of listbox].ListCount
 
M

Marshall Barton

As a UI performance enhancement, it is normal for datasets
(form RecordSource, table/query DataSheet, combo/list box
RowSource) to be populated at a relatively low priority
after the visible portion appears. So, it it normal for
there to be delays as you scroll down a long(?) list. If it
did not do this, there would be a much longer delay when the
form is opened.

The sort order is irrelevant. I was trying to say that the
ListCount property forces all the records to be loaded so it
can calculate the value it is supposed to return.

If the list box is not returning the expected set of records
(after scrolling to the end), then take a good look at its
RowSource query's criteria to make sure you are filtering
the records the way you intended.
--
Marsh
MVP [MS Access]

What do you mean loaded in order? They are input with a unique id number,
but I am pulling them in order of the circuit field which is a text field. I
dont' see why it doesn't always work either, when the users first complained
I was sure they were wrong until I saw it for myself.

Marshall Barton said:
All the records must be loaded in ordet to count them. This
is an old, tried and true techique. Unless they changed
something lately, it should work.

I don't see how your button could get the wrong number.

How does setting a variable to the count of the list box help it pull all
items? I had a command button that if I selected I had a stop in the code so
I could read the list count it read as follows.

Dim testid As Long
testid = Me.[name of listbox].ListCount

sometimes it would give me the 1002 record count sometimes it would only
return 700 records when there are 1002 records in my table? I tried out what
you suggested and I got the correct record count twice, but I'm still
skeptical since I was getting the correct answer sometimes before.


:

Cynthia wrote:

I have a command button that opens a form that has an unbound list box.
The query for the list box selects 3 fields from a table no where clause.
Sometimes when we open the form all records appear in the list box, but other
times only a portion of the records in the table appear in the list box?????


You might try adding this to the second form's Load event:

Dim dummy As Long
dummy = Me.[name of listbox].ListCount
 
C

Cynthia

Thank you so much, now I can understand why adding this code helps. Now
that I have put the code you mentioned on the form load event it is working
fine.

Marshall Barton said:
As a UI performance enhancement, it is normal for datasets
(form RecordSource, table/query DataSheet, combo/list box
RowSource) to be populated at a relatively low priority
after the visible portion appears. So, it it normal for
there to be delays as you scroll down a long(?) list. If it
did not do this, there would be a much longer delay when the
form is opened.

The sort order is irrelevant. I was trying to say that the
ListCount property forces all the records to be loaded so it
can calculate the value it is supposed to return.

If the list box is not returning the expected set of records
(after scrolling to the end), then take a good look at its
RowSource query's criteria to make sure you are filtering
the records the way you intended.
--
Marsh
MVP [MS Access]

What do you mean loaded in order? They are input with a unique id number,
but I am pulling them in order of the circuit field which is a text field. I
dont' see why it doesn't always work either, when the users first complained
I was sure they were wrong until I saw it for myself.

Marshall Barton said:
All the records must be loaded in ordet to count them. This
is an old, tried and true techique. Unless they changed
something lately, it should work.

I don't see how your button could get the wrong number.


Cynthia wrote:

How does setting a variable to the count of the list box help it pull all
items? I had a command button that if I selected I had a stop in the code so
I could read the list count it read as follows.

Dim testid As Long
testid = Me.[name of listbox].ListCount

sometimes it would give me the 1002 record count sometimes it would only
return 700 records when there are 1002 records in my table? I tried out what
you suggested and I got the correct record count twice, but I'm still
skeptical since I was getting the correct answer sometimes before.


:

Cynthia wrote:

I have a command button that opens a form that has an unbound list box.
The query for the list box selects 3 fields from a table no where clause.
Sometimes when we open the form all records appear in the list box, but other
times only a portion of the records in the table appear in the list box?????


You might try adding this to the second form's Load event:

Dim dummy As Long
dummy = Me.[name of listbox].ListCount
 

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