473,382 Members | 1,743 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Cascading listboxes

Can someone tell me how to modify this code to have the second listbox be dependent on the first? I can't seem to get the rowsource in the second listbox to point to strPark. My two listboxes are mslPark and mslSpecies. Thanks!!

Kara

Private Sub cmdOK_Click()
Dim varItem As Variant
Dim strPark As String
Dim strSpecies As String
Dim strSQL As String
For Each varItem In Me.mslPark.ItemsSelected
strPark = strPark & ",'" & Me.mslPark.ItemData(varItem) _
& "'"
Next varItem
If Len(strPark) = 0 Then
strPark = "Like '*'"
Else
strPark = Right(strPark, Len(strPark) - 1)
strPark = "IN(" & strPark & ")"
End If
For Each varItem In Me.mslSpecies.ItemsSelected
strSpecies = strSpecies & ",'" & Me.mslSpecies.ItemData(varItem) _
& "'"
Next varItem
If Len(strSpecies) = 0 Then
strSpecies = "Like '*'"
Else
strSpecies = Right(strSpecies, Len(strSpecies) - 1)
strSpecies = "IN(" & strSpecies & ")"
End If
strSQL = "SELECT qryTest.* FROM qryTest " & _
"WHERE qryTest.[ParkName] " & strPark & _
"qryTest.[Species] " & strSpecies & ";"
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Set db = CurrentDb
Set qdf = db.QueryDefs("qryTest")
qdf.SQL = strSQL
Set qdf = Nothing
Set db = Nothing
DoCmd.OpenQuery "qryTest"
DoCmd.Close acForm, Me.Name
End Sub
Jul 10 '06 #1
0 1015

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Humpty Dumpty | last post by:
Hi folks, here's a challenge: I have a dynamically created cascading menu in Tkinter that can be quite large because it is created from a file. I tried using lazy creation so only the menu item...
1
by: JMosey | last post by:
Not sure if this has been covered ( a google search came up pretty bare). I have a site that: - has multi-level cascading menus - floats center of the browser window - Will have fairly heavy...
4
by: bill yeager | last post by:
I have several template columns inside of a datagrid. Inside of these template columns are databound listboxes: <asp:TemplateColumn HeaderText="Crew Chiefs"> <ItemTemplate> <asp:listbox...
0
by: Terry D | last post by:
I'm having an issue with an ASP.NET page (VS.NET 2003, VB.NET, Oracle back end). The page uses the standard VS.NET grid to display the records from a particular table. The user can edit certain...
1
by: Ryan Ternier | last post by:
I have two listboxes, and allow users to move items between them via the following function: function SwitchList(fbox, tbox){ var arrFbox = new Array(); var arrTbox = new Array(); var...
0
by: Luis Esteban Valencia | last post by:
have a problem and I'm not sure how to handle/fix it. I have three listboxes on my page. The first listbox has a list of software products. When you select an item in the Products listbox, then...
4
by: Tim Ferguson | last post by:
Okay: I know this may not seem like much to you, but I have at last worked out how to connect two database-linked listboxes using ADO dotNet. You know: the first one has countries, and when you...
2
by: salad | last post by:
This is a tip on how to speed up listboxes DRAMATICALLY. Persons that would benefit are those that are constantly updating the rowsource of a listbox/combobox in order to filter and sort the data...
1
by: wizardRahl | last post by:
Hello all, I am fairly new to Access. I have a decent understanding of database concepts from working with sql developer and Oracle's APEX. In MS access, I would like to know how to populate a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.