X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
   Reply to this topicStart new topic
> Load Listbox From Multiple Texboxes, Access 2016    
post Dec 26 2017, 11:05 AM

Posts: 791
Joined: 21-September 07
From: South Dakota

I have a bound form called frmCabinetsDetailsEdit which is bound to a table called tblCabinets. On this form I have a listbox called lsteSubfolders whose row source is SELECT tblSubFolders.SubFolderID, tblSubFolders.SubFolderName FROM tblSubFolders; Also located on the frmCabinetsEditDetails are a series of 20 textboxes that are hidden called IndexKey01Label,IndexKey02Label,IndexKey03Label,IndexKey04Label...IndexKey20Labe
l which are bound to their fields in tblCabinets. What I am trying to do is populate the listbox with the values from the text boxes. I have come up with this but it does not work.

Private Sub Form_Load()
'set controls status
Me.cmdDone.Enabled = False
initializeECabinetKey = False
Me.lsteSubFolder.Enabled = False
Me.cmdAddeSubfolder.Enabled = False

Me.cmdCancel.Visible = True

' Me.cmdSave.Visible = True
Me.lblCabinetName.Visible = True
Me.Caption = "Modify existing eCabinet"
'Me.lblCabinetTitle.Caption = "Add a New eCabinet"

'Load lsteIndexes.
With lsteIndexFields
.AddItem ""
.List(.ListCount - 1, 0) = txtIndexKey01Label.Text
.List(.ListCount - 1, 1) = txtIndexKey02Label.Text
.List(.ListCount - 1, 2) = txtIndexKey03Label.Text
.List(.ListCount - 1, 3) = txtIndexKey04Label.Text
.List(.ListCount - 1, 4) = txtIndexKey05Label.Text
.List(.ListCount - 1, 5) = txtIndexKey06Label.Text
.List(.ListCount - 1, 6) = txtIndexKey07Label.Text
.List(.ListCount - 1, 7) = txtIndexKey08Label.Text
.List(.ListCount - 1, 8) = txtIndexKey09Label.Text
.List(.ListCount - 1, 9) = txtIndexKey10Label.Text
.List(.ListCount - 1, 10) = txtIndexKey11Label.Text
.List(.ListCount - 1, 11) = txtIndexKey12Label.Text
.List(.ListCount - 1, 12) = txtIndexKey13Label.Text
.List(.ListCount - 1, 13) = txtIndexKey14Label.Text
.List(.ListCount - 1, 14) = txtIndexKey15Label.Text
.List(.ListCount - 1, 15) = txtIndexKey16Label.Text
.List(.ListCount - 1, 16) = txtIndexKey17Label.Text
.List(.ListCount - 1, 17) = txtIndexKey18Label.Text
.List(.ListCount - 1, 18) = txtIndexKey19Label.Text
.List(.ListCount - 1, 19) = txtIndexKey10Label.Text

End With

End Sub

Any ideas would be great.
Go to the top of the page
post Dec 26 2017, 11:28 AM

Posts: 1,324
Joined: 26-December 12
From: Western Ma.,L.I.,N.Y.,Jupiter,Fl.

I'm not sure I'm following what your trying to do or rather how your trying to do it.

Are you trying to take all the fields on your form and list them in your listbox?
if so, why not just loop thru your recordset?
Go to the top of the page
post Dec 26 2017, 11:44 AM

Posts: 791
Joined: 21-September 07
From: South Dakota

That is exatly what I am trying to do. Would you have an example of looping through my record set?
Go to the top of the page
post Dec 26 2017, 12:13 PM

UA Admin
Posts: 33,786
Joined: 20-June 02
From: Newcastle, WA

How do you assign the values to the text boxes in the first place?

Go to the top of the page
post Dec 26 2017, 01:37 PM

Posts: 791
Joined: 21-September 07
From: South Dakota

When you load the form, it displays the fits records in the table tblCabinets. I have the a combo box called cmbCurrentECabinet which record source is SELECT tblCabinets.CabinetName FROM tblCabinets; When the user changes the cmbCurrentECabinet I am trying it to get it to move to that specific record but that is not working. But everything should be based on the selection in the combo box cmbCurrentECabinet .
Go to the top of the page
post Dec 26 2017, 01:38 PM

Posts: 4,553
Joined: 11-November 02

A couple of things...in addition to George's question:

First, having Fields/Controls named


strongly suggests that your data is not Normalized.

Secondly, having 20 hidden Controls on a Form is just, to say the least, odd!

And lastly, in order to refer to the .Text Property of a Control, the Control must first have Focus, which obviously is not the case, with your given code.

I think it would probably help us help you if you gave us an explanation, in plain, non-Access language, of what you're trying to accomplish here, i.e. what your business needs are.

Linq ;0)>
This post has been edited by missinglinq: Dec 26 2017, 01:39 PM
Go to the top of the page
post Dec 26 2017, 02:27 PM

Posts: 791
Joined: 21-September 07
From: South Dakota

We are taking a old VB 6 application and porting it to Access 2016. THe old application used a lot of control arrays which no longer exists. The original application is a document management solution.

the main table is denormalized monstrosity that we are having to keep until we have time to properly go in and do a proper job. The management said get it working in access now, and then they might allocate monies to move it to vb.net and do a proper job of it. Been to them several times and they are not moving on this initial release. We need to keep the original tabe structure because we need to upgrade several clients also.

I know its ugly as sin but its what I got to do right now.

The top of the hierarchy is the Cabinet table which contains individual Cabinet information + 20 fields of caption data, Name, Date, Company Name, which are kept in the IndexKey01Label through IndexKey20Lable fields.

I am trying to move the 20 fields of data ( they are not all used all the time) to the listbox.
Go to the top of the page
post Dec 26 2017, 05:12 PM

UtterAccess VIP
Posts: 10,171
Joined: 10-February 04
From: South Charleston, WV

There is an example here.
Go to the top of the page

Custom Search
RSSSearch   Top   Lo-Fi    21st October 2018 - 09:22 AM