With Warm Regards,
Hi Art
There is little functional difference between a combobox and a listbox as far as the RowSource is concerned, so you do it just the same way as you do for a combo-to-combo cascading relationship:
Private Sub cboPriFolders_AfterUpdate()
Dim sRowSource As String
sRowSource = "SELECT tblSubFolder.intSubFolderID, tblSubFolder.txtSubFolderName, " _
& "tblSubFolder.intPriFolderID FROM tblSubFolder"
If Not IsNull(cboPriFolders) Then
sRowSource = sRowSource & " WHERE tblSubFolder.intPriFolderID=" & cboPriFolders
End If
lstSubFolders.RowSource = sRowSource
End Sub
Best wishes,
Graham
From: MS_Access_Professionals@yahoogroups.com [mailto:MS_Access_Professionals@yahoogroups.com]
Sent: Monday, 31 July 2017 09:30
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Populate list box via a combo box
I was looking at the samples on the site but could not find what I am looking for. I have a series of combo boxes and a list box set up as follows which are related, they populate the combo below them.:
cboCabinets:
RowSource:
SELECT tblCabinet.intCabinetID, tblCabinet.txtCabinetName, tblCabinet.txtCabinetLocation FROM tblCabinet;
After_Update:
Dim sDrawerLoadSource As String
sDrawerLoadSource = "SELECT [tblDrawer].[intDrawerID], [tblDrawer].[intCabinetID], [tblDrawer].[txtDrawerName] " & _
"FROM tblDrawer " & _
"WHERE [intCabinetID] = " & Me.cboCabinet.Value
Me.cboDrawer.RowSource = sDrawerLoadSource
Me.cboDrawer.Requery
cboDrawer:
RowSource:SELECT tblDrawer.intDrawerID, tblDrawer.intCabinetID, tblDrawer.txtDrawerName, tblDrawer.txtDrawerLocation FROM tblDrawer;
After_Update:
Dim sPriFoldersLoadSource As String
sPriFoldersLoadSource = "SELECT [tblPrimaryFolder].[intPriFolderID], [tblPrimaryFolder].[intDrawerID], [tblPrimaryFolder].[txtPriFolderName] " & _
"FROM tblPrimaryFolder " & _
"WHERE [intDrawerID] = " & Me.cboDrawer.Value
Me.cboPriFolders.RowSource = sPriFoldersLoadSource
Me.cboPriFolders.Requery
cboPriFolders
RowSource:SELECT tblPrimaryFolder.intPriFolderID, tblPrimaryFolder.intDrawerID, tblPrimaryFolder.txtPriFolderName, tblPrimaryFolder.txtPriFolderLocation FROM tblPrimaryFolder;
After_Update
This were I get lost. I am not sure how to write the connection code for the list box:
lstSubfolders
RpwSource: SELECT tblSubFolder.intSubFolderID, tblSubFolder.txtSubFolderName, tblSubFolder.intPriFolderID FROM tblSubFolder;
Now a Primary folder can have several subfolders which can be loaded into the list box. Hope youcan help.
Thank you
Art Lorenzini,
Sioux Falls, SD
Posted by: Art Lorenzini <dbalorenzini@yahoo.com>
Reply via web post | • | Reply to sender | • | Reply to group | • | Start a New Topic | • | Messages in this topic (3) |
Tidak ada komentar:
Posting Komentar