Solved

Filling a list box

Posted on 2002-03-20
6
219 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

762 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

20 Experts available now in Live!

Get 1:1 Help Now