473,395 Members | 1,972 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,395 software developers and data experts.

Access 2003 – Multi-Column List Box – Select Multiple Items

Access 2003 – Multi-Column List Box – Select Multiple Items

I have a multi-column (3 columns) list box that works well to select one set of records or all sets of records (based on the first field in the list box). I need to it also select multiple sets of records (Multi-Select = Extended).

I modified my code based on code I found on some Internet site which gave an example using three fields in a three field table. It loops through the items in the list box and selects those fields to populate the list box.

My table has about 200 fields and the three fields I need are like number 32, 4, and 132 in the table. Can someone help me modify the code to get the fields I need? Here’s my code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub SelectedContract_Click()
  2. ' Declare variables
  3.     Dim db As DAO.Database
  4.     Dim qdf As DAO.QueryDef
  5.     Dim varItem As Variant
  6.     Dim strCriteria As String
  7.     Dim strSQL As String
  8. ' Get the database and stored query
  9.     Set db = CurrentDb()
  10.     Set qdf = db.QueryDefs("qry_OptimizeIt3")
  11. ' Loop through the selected items in the list box and build a text string
  12.     For Each varItem In Me!List10.ItemsSelected
  13.         strCriteria = strCriteria & ",'" & Me!List10.ItemData(varItem) & "'"
  14.     Next varItem
  15. ' Check that user selected something
  16.     If Len(strCriteria) = 0 Then
  17.         MsgBox "You did not select anything from the list" _
  18.             , vbExclamation, "Nothing to find!"
  19.         Exit Sub
  20.     End If
  21. ' Remove the leading comma from the string
  22.     strCriteria = Right(strCriteria, Len(strCriteria) - 1)
  23. ' Build the new SQL statement incorporating the string
  24.     strSQL = "SELECT * FROM dbo_OptimizeIt1 " & _
  25.              "WHERE dbo_OptimizeIt1.LeaseMasterContractId IN(" & strCriteria & ");"
  26. ' Apply the new SQL statement to the query
  27.     qdf.SQL = strSQL
  28. ' Open the query
  29.     DoCmd.OpenReport "rpt_OptimizeItReport1", acViewPreview, , strFilter = "[LeaseMasterContractId] = '" & Me.List10 & "'"
  30.     ' Empty the memory
  31.     Set db = Nothing
  32.     Set qdf = Nothing
  33. End Sub
Krazy (Bill) Kasper
Aug 11 '08 #1
1 4856
NeoPa
32,556 Expert Mod 16PB
While posting code can be useful for reference purposes, it's no substitute for a clearly stated question.
Aug 11 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Sam | last post by:
Trying to change the visible property on a command button (access97) based on a record felid on the form. The felid is a check box felid and I am trying to make the button disappear with the...
8
by: David Bray | last post by:
I have an Access database on an ISP's web-space which is accessed through ASP - all standard stuff. Can anyone tell me whether ASP's object.context methods for transactions will work with...
3
by: Terry Block | last post by:
We have an Access 97 database app that we'd like to enable (not convert) for Access 2003. We still have users running 97 and are not prepared to upgrade everyone who uses this database to the 2003...
1
by: Mike | last post by:
Hi Hi We are currently upgrading from access 97 to office 2003 on site. We would like to upgrade our access databases to Access 2003 but we wish to remove Microsoft access software from our end...
47
by: ship | last post by:
Hi We need some advice: We are thinking of upgrading our Access database from Access 2000 to Access 2004. How stable is MS Office 2003? (particularly Access 2003). We are just a small...
52
by: Neil | last post by:
We are running an Access 2000 MDB with a SQL 7 back end. Our network guy is upgrading to Windows Server 2003 and wants to upgrade Office and SQL Server at the same time. We're moving to SQL Server...
3
by: Alex | last post by:
Hello, I am running an Access 2003 database, quite modest in size, that is used by upwards of 5 users. I need to modify the database such that these users can work simultaneously and, in some...
13
yolenman
by: yolenman | last post by:
Hello - This is my first posting to this group, so please bear with me. Also note, that while I'm intelligent, databases are not in my field of knowledge. I'm working with a small limousine...
0
by: slider | last post by:
hey all, first question i have is, can i create a database using Microsoft Access 2003 and run it on a local network for multi access and simultaneous access? or do i need to use a program such as...
0
by: TLarge | last post by:
I wish to install an access 2003 in a multi user enviroment. My client does not wish to install Access on his machines as he is running open office. I am familiar with spliting data bases and also...
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:
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.