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

Reference a 2nd Column in Listbox in Code

Access 2003 Frt end, SQL 2000 Back end

My listbox has 2 columns "UserID" & "FullName" (UserID is a Primary
Key)

I am trying to loop thru the multi-select listbox to print a separate
report for each user selected.

However, I need for the UserID and Fullname from the listbox to print
on the report. Ihave tried a couple of different options below without
success. I can't seem to grab the FullName from the 2nd column. I may
be going about this all wrong.

The msgbox line is for testing w/o printing.

As Always, Any Help Appreciated!
Dim stDocName As String
Dim Myname As Variant
Dim User1, User2 As String
For Each Myname In Me!List6.ItemsSelected

User1 = Me.List6.ItemData(Myname)
'User2 = Me.List6.Column(1).ItemData(Myname)
'User2 = DLookup("[UserID]", "tblReg", "[UserID] =" & User1)

MsgBox (User1 & vbCrLf & vbCrLf & User2)

'stDocName = "rptScanSt_Multi"
'DoCmd.OpenReport stDocName, acViewPreview

Next Myname

Dec 12 '06 #1
1 5457
Apparently to get to data in a listbox you need BOTH index and row.
Here is code from a form that is executed on the dblclick event and
then it does a compare for days greater than 30 for the row
selected.....

if me.CNDAPPBx.Column(9, me.CNDAPPBx.ListIndex + 1) 30 then
Try playing with that.

Ron

Dec 13 '06 #2

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

Similar topics

2
by: Nicolas Favre-Félix | last post by:
Hello, I have a little problem using Tkinter: I'd like to make a interface with 3 labels on the left, facing with 3 Entry on the right, a button below Entrys, and a Listbox under all. I could...
4
by: Giulio | last post by:
Hello, I have a continuous form with a combo box inside. From the combo box I can pick some values which, by the "after-update" event, change some other combo box values determined by a query....
0
by: Darryl Kerkeslager | last post by:
Access 2002 on Win98 at least, not tested elsewhere: Bug: The ListCount property of an unbound listbox may be incorrect if you use column heads. Model: Set up a simple database with two...
7
by: Douglas Buchanan | last post by:
I cannot access certain column values of a list box using code. I have a list box 'lstPrv' populated by the query below. SELECT tblPrv.fkPrvID, lkpCat.CatNm, lkpSrv.SrvNm, lkpCat.pkCatID,...
5
by: matthewtec | last post by:
I see that it is possible to have a multicolumn ListBox: lstOne.MultiColumn = True lstOne.ColumnWidth = 10 but the only way I have seen to have the items in the listbox print in the next...
4
by: Peter Gibbs | last post by:
I need some help with this problem. I'm using Access 2002 with XP. My problem is with a 2-column listbox. My VBA code puts text data into the listbox. The problem is that the text data...
1
by: eric | last post by:
Hi, Can anyone please explain to me how I can cop selected items from a multi listbox(simple) to another multi listbox? the code I found on msdn only seems to support single column copies, i...
3
dbushcmohle
by: dbushcmohle | last post by:
Hello, I currently have some list boxes that are referenced by the column number... (see below) If lstLots.Column(7) = 0 Then How do I reference the Column name instead....?
4
by: Lou O | last post by:
Is it possible to use the row (index) of a list box as control source Property for a text box? Example: Text1.ControlSource Property is set to "= List1.Column(0,2)" in design view. When I open...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.