ListBox Properties

Unified

Registered User.
Local time
Today, 01:24
Joined
Aug 26, 2004
Messages
18
Ok, I have a Form with a ListBox and a number of ComboBoxes that contain information that is displayed in the ListBox. I use the ComboBoxes to enter information into the ListBox. But I would like to be able to click on a record in the ListBox and have the ComboBoxes auto-fill with the data in the ListBox/record so I can edit it that way instead of cycle through all the records with the 'Next Record' button. Does anyone know which property of a ListBox I would edit to make it so that when a record in the ListBox is clicked, the ComboBoxes will be autofilled? Or is it a property of the Form that I need to edit? Any help would be appreciated..
*Edit* I tried to upload an example, but got the 'file too big' error. So, if anyone would like me to send it to them via email or instant messanger, leave your s/n and I'll get that to you. Thanks again.
 
Unified,

Tools --> Database Utilities --> Compact/Repair
Then ZIP
Then attach

Wayne
 
Any help would be appreciated.
 

Attachments

Unified,

Got your sample (been a busy week so far). Nice looking form. To move
data between the listbox <--> combo boxes will require code. Property
settings won't do it.

You can use the On-Click (or AfterUpdate) of the ListBox to:

Me.SomeCombo = Me.ListBox.Column(0)
Me.SomeOtherCombo - Me.ListBox.Column(1)

and so on. This does assume that it's NOT a multi-select listbox.

Moving data from the combos to the listbox is a little more complex.

Are we on the right track? I'll look back in later.

Wayne
 
WayneRyan said:
Unified,

You can use the On-Click (or AfterUpdate) of the ListBox to:

Me.SomeCombo = Me.ListBox.Column(0)
Me.SomeOtherCombo - Me.ListBox.Column(1)

and so on. This does assume that it's NOT a multi-select listbox.

Moving data from the combos to the listbox is a little more complex.

Are we on the right track? I'll look back in later.

Wayne

Endless amounts of praise. Thank you very much... that's prettymuch exactly what I was looking for. Just one problem on that, it works for most every ComboBox that I have except one. The Count field on the ListBox. When I write the code out I get the Data Type Mismatch error. I suspected it was because in the tblJobs table, Count is a Number field, and the ComboBox wasn't. So I checked the table and Count is a Number field. But when I switch the property of the ComboBox to that of General Number, I still get the error. Any ideas on why that is or a way to fix it?
As it is now, the code for my ListBox is as follows (The line I receive the error is the "Me.Count = Me.lbDisplay.Column(5)" line)
Code:
Private Sub lbDisplay_AfterUpdate()
 
    Me.JobID = Me.lbDisplay.Column(0)
    Me.CustomerID = Me.lbDisplay.Column(1)
    Me.InvoiceID = Me.lbDisplay.Column(2)
    Me.[Item Done] = Me.lbDisplay.Column(3)
    Me.Distress = Me.lbDisplay.Column(4)
    Me.Count = Me.lbDisplay.Column(5)
    Me.ColorID = Me.lbDisplay.Column(6)
    Me.Hours = Me.lbDisplay.Column(7)
    Me.Cost = Me.lbDisplay.Column(8)
    Me.Price = Me.lbDisplay.Column(9)
    Me.tbDescription = Me.lbDisplay.Column(10)
    Me.Designer.Text = ""
And also, I dont know if its possible or not. But say there is a ComboBox that isn't included in the ListBox, but is still on the Form, and when I click on a record in the ListBox I want the text in the ComboBox to be deleted as to make it easy to enter new data. Ideas on how to do that? Any other help on this will be greately appreciated.
 
U,

Well "Count" is reserved by SQL (and maybe JET). I wouldn't use it as a name.

I really think that we're heading down the wrong road here. What exactly are
you trying to do?

Access (with bound forms) will pretty much handle all of the data manipulation
that you need. You can use combos and ListBoxes as "Search aids", but when
you try to use them for data entry, you make a lot a lot more work for yourself.

Need more info,
Wayne
 
Ok, as for what im doing.. The combo/textboxes are for data entry. On the Form I've been using the New Record button and entering the data in the combo/textboxes. I have all that working the way I want it to.. But say I wanted to edit a certain record. I think it would be easier to be able to click on a record in the ListBox, and have the comboboxes display all the data for that record and edit which ever entry (Customer Name, Price, ColorID, etc) needed. Because, as it is now, I have to click on Next Record and scroll through all the records until I find the one I want, and edit it from there. This isn't a big problem, just more of an inconvenience than anything. It is sort of a pain to scan through 150+ records by using Next Record until I come to the one I want. It would be much easier in my opinion to to just scroll through the ListBox, click the record I'm looking for, and edit the information stored in the combo/textboxes.
 

Users who are viewing this thread

Back
Top Bottom