Solved

Filling a list box

Posted on 2002-03-20
6
221 Views
Last Modified: 2010-05-02
Maybe I'm missing something here or possibly I'm just going stark staring mad but....

I have a dialog box with a listbox control in it. I have associated this with a command in my dataenvironment by listing the datasource as my dataenvironment, the datamember as my command and the datafield as one of the fields from the command. (The actual command is a simple table scan).

When I run the dialog I get nothing in the listbox. However if I create a textbox on the dialog and bind it to the database in the exactly the same way the field from the first row of the table is displayed.

So the question is what have I missed out on the listbox or is there something else I want to do.

Steve
0
Comment
Question by:mouatts
6 Comments
 
LVL 18

Expert Comment

by:mdougan
ID: 6883548
You will probably need to use a "datacombo" instead of the standard listbox.  The standard listbox might work if you set the style to drop-down combo, but I don't think any of the "list" modes would work, nor would a standard fully expanded listbox.

If you think about it, which element in the list is bound to the row?

With a datacombo, I think that you can specify one datasource/datamember for the list, and another for the text area of the combo.
0
 
LVL 11

Author Comment

by:mouatts
ID: 6883642
I understand what you are saying, but if the datafields weren't available for use why are they part of the listbox in the first place.

I think you are confusing listboxes with combos, there is no such style available on a listbox.

According to the VBHelp what I have done is valid.

Steve
0
 
LVL 18

Accepted Solution

by:
mdougan earned 50 total points
ID: 6884136
Well, what I was doing, talking about combos, is suggesting that if you used a combo, set either as a drop-down combo, or a simple combo, then my guess is that the text portion of the combo would be bound correctly to your datafield and display the data properly.

Your comment about "why are they part of the listbox..." was valid, so, the question was, how do we get it to work?  Well, I was on the right track at first.  A listbox can only be set to an item that already exists in the list.  If your list is empty, then when you try to put a bound column value into the selected listitem, it wont match anything in the list, and so, it wont work.

To get this to work, you must first fill your listbox with all of the distinct occurrences of that column in the database.  Then, you will see as you navigate to new rows, that the selection will highlight the element in the list that matches the element in the datafield.

So, my other suggestion was to switch to the datalist, which might allow you to specify a different source for the list, which would mean that you won't have to write code to fill the list yourself....
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 49

Expert Comment

by:DanRollins
ID: 7634196
Hi mouatts,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept mdougan's comment(s) as an answer.

mouatts, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:Jgould
ID: 7641817
request for deletion is made here

http://www.experts-exchange.com/Community_Support/Q_20438519.html

if no one objects will go ahead in 72 hours

Jgould-EE Moderator
0
 
LVL 1

Expert Comment

by:kodiakbear
ID: 7666065
Moving to the paq

kb
Experts Exchange Moderator
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now