473,378 Members | 1,495 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,378 software developers and data experts.

Listbox ListCount with RecordSet

This is baffling to me. I'm using Access 2002. If I create an
unbound form and put an unbound listbox on it (List0) and then add the
following code to the Form_Load event:

Private Sub Form_Load()

List0.ColumnHeads = False
Set List0.Recordset = Nothing

MsgBox List0.ListCount

End Sub

Why do I get a message box saying ListCount is 1? Shouldn't it be 0?

Bruce

Feb 26 '07 #1
2 7544
The listcount for an Access Listbox starts at 1. If you add one element
to the Rowsource of your listbox it will also display a count of 1. If
you add more than one element to the rowsource of your listbox it will
display the count of elements. I think when the count starts at 1 is is
called "non ordinal"? An Access collection object also starts at a
count of 1. But they (Microsoft) changed this convention in .Net, and
everything starts at a count of 0. More consistent this way, as you can
see.

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Feb 26 '07 #2
On Feb 26, 7:31 pm, Rich P <rpng...@aol.comwrote:
The listcount for an Access Listbox starts at 1. If you add one element
to the Rowsource of your listbox it will also display a count of 1. If
you add more than one element to the rowsource of your listbox it will
display the count of elements. I think when the count starts at 1 is is
called "non ordinal"? An Access collection object also starts at a
count of 1. But they (Microsoft) changed this convention in .Net, and
everything starts at a count of 0. More consistent this way, as you can
see.

Rich

*** Sent via Developersdexhttp://www.developersdex.com***
Not sure if this changes after 97 as I have never tried it, but the
list count does read 0 when the RowsourceType is a Value List or a
Field List - it only seems to be 1 for a Table/Query. Probably much
like a query that returns no records, in query view it usually
produces one blank line.

Feb 27 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: R.Wieser | last post by:
Hello All, I'm trying to get a "Virtual Listbox" to work. I've currently got a form, and used CreateWindowExA to create a ListBox with the LBS_OWNERDRAWFIXED and LBS_NODATA flags on it. I've...
4
by: Alienz | last post by:
I have a subform where I have a subform with 20 options to select from. When I set the multiselect property to simple and select multiple options, nothing is stored. I have another table with...
5
by: Melissa Cowan | last post by:
I am using Access 2000. I have the Developer's handbook and got the code for the mulit select listbox from there. It sends the selected value to another listbox, lstselected. What I need to do is...
13
by: Gittyup | last post by:
Help please, We have a form, based on a query, that contains a listbox. The contents of the listbox are based on the results of the query. When the form is opened, the user selects an item...
3
by: Alan Lane | last post by:
Hello world: I have a Parent form with a combobox, where the user selects a Contract or Estimate number. Then, on a subform, I have a listbox that gets filled with the details of the selected...
3
by: BVH | last post by:
Hi, I'm currently having a problem with a vb6 project I once wrote that needs to be converted to vb.NET. The problem is as follows : On a form I have a listbox and two commandbuttons. The 2...
1
by: andrew.panin | last post by:
Hi there! I've got a trouble with these things. What's going on? 1ST STEP: we have ListBox item. Let's call it ListBox1. We're adding four values to it using AddItem method:...
6
by: ortaias | last post by:
I have a listbox which can display all records or provide a limited list based on a filter derived from an optiongroup. The code works except in the one situation where the listbox filter is...
1
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.