Connecting Tech Pros Worldwide Forums | Help | Site Map

Reference a 2nd Column in Listbox in Code

Dale
Guest
 
Posts: n/a
#1: Dec 12 '06
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


Ron2006
Guest
 
Posts: n/a
#2: Dec 13 '06

re: Reference a 2nd Column in Listbox in Code


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

Closed Thread