refer to second column of listbox

Hi,


I have a multi selected listbox. How can I refer to the second column of the 
listbox?
Me.lstContract.ItemData(varItem).column(1) ???

Dim varItem As Variant

    For Each varItem In Me.lstContract.ItemsSelected
        gstrReportFilter = "[Ck_ContractID]='" & 
Me.lstContract.ItemData(varItem) & "'"
        ''DoCmd.OpenReport "rptCoFundActivity_k" '', , , gstrReportFilter
        DoCmd.OpenReport "rptCostShareContribution_k", acViewPreview '', , 
gstrReportFilter
    Next varItem


SF 


0
SF
12/4/2009 10:04:34 AM
access 16762 articles. 3 followers. Follow

6 Replies
1093 Views

Similar Articles

[PageSpeed] 1

SF,
    When a value has been selected, it should be just...
        lstContract.Column(1)
-- 
    hth
    Al Campagna
    Microsoft Access MVP
    http://home.comcast.net/~cccsolutions/index.html

    "Find a job that you love... and you'll never work a day in your life."


"SF" <samnangs@pactcambodia.org> wrote in message 
news:OCvhLnMdKHA.2188@TK2MSFTNGP04.phx.gbl...
> Hi,
>
>
> I have a multi selected listbox. How can I refer to the second column of 
> the listbox?
> Me.lstContract.ItemData(varItem).column(1) ???
>
> Dim varItem As Variant
>
>    For Each varItem In Me.lstContract.ItemsSelected
>        gstrReportFilter = "[Ck_ContractID]='" & 
> Me.lstContract.ItemData(varItem) & "'"
>        ''DoCmd.OpenReport "rptCoFundActivity_k" '', , , gstrReportFilter
>        DoCmd.OpenReport "rptCostShareContribution_k", acViewPreview '', , 
> gstrReportFilter
>    Next varItem
>
>
> SF
> 


0
Al
12/4/2009 1:35:43 PM
"Al Campagna" <newsgroups@comcast.net> wrote in message 
news:eBVrtaOdKHA.4780@TK2MSFTNGP04.phx.gbl...
> SF,
>    When a value has been selected, it should be just...
>        lstContract.Column(1)

Not for a multiselect combo box -- then you need to index the row as well as 
the column:

    .Me.lstContract.Column(1, varItem)


-- 
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

0
Dirk
12/4/2009 2:04:58 PM
SF -

The columns in a list box, combo box, or drop-down list box start with 1 
(first column).   You can just use Me.lstContract.column(2) for the second 
column.
-- 
Daryl S


"SF" wrote:

> Hi,
> 
> 
> I have a multi selected listbox. How can I refer to the second column of the 
> listbox?
> Me.lstContract.ItemData(varItem).column(1) ???
> 
> Dim varItem As Variant
> 
>     For Each varItem In Me.lstContract.ItemsSelected
>         gstrReportFilter = "[Ck_ContractID]='" & 
> Me.lstContract.ItemData(varItem) & "'"
>         ''DoCmd.OpenReport "rptCoFundActivity_k" '', , , gstrReportFilter
>         DoCmd.OpenReport "rptCostShareContribution_k", acViewPreview '', , 
> gstrReportFilter
>     Next varItem
> 
> 
> SF 
> 
> 
> .
> 
0
Utf
12/4/2009 2:20:01 PM
If you want to refer to specific column and specific row
   Me.ListContract.Column(2,50)
Refers to the third column of the 51st row.

So I believe (you can test) you can get the appropriate value using
   me.ListContract.Column(1,VarItem)

John Spencer
Access MVP 2002-2005, 2007-2009
The Hilltop Institute
University of Maryland Baltimore County

SF wrote:
> Hi,
> 
> 
> I have a multi selected listbox. How can I refer to the second column of the 
> listbox?
> Me.lstContract.ItemData(varItem).column(1) ???
> 
> Dim varItem As Variant
> 
>     For Each varItem In Me.lstContract.ItemsSelected
>         gstrReportFilter = "[Ck_ContractID]='" & 
> Me.lstContract.ItemData(varItem) & "'"
>         ''DoCmd.OpenReport "rptCoFundActivity_k" '', , , gstrReportFilter
>         DoCmd.OpenReport "rptCostShareContribution_k", acViewPreview '', , 
> gstrReportFilter
>     Next varItem
> 
> 
> SF 
> 
> 
0
John
12/4/2009 2:21:39 PM
"Daryl S" <DarylS@discussions.microsoft.com> wrote in message 
news:637D3EBF-B7F5-4F85-B4BA-7E05B2CD721E@microsoft.com...
> SF -
>
> The columns in a list box, combo box, or drop-down list box start with 1
> (first column).   You can just use Me.lstContract.column(2) for the second
> column.


I'm sorry, but that is wrong.  The Columns collection is 0-based, so the 
first column is .Column(0).

-- 
Dirk Goldgar, MS Access MVP
Access tips: www.datagnostics.com/tips.html

(please reply to the newsgroup)

0
Dirk
12/4/2009 2:49:12 PM
Sorry - I was thinking of the bound column of a list box, combo box, or 
drop-down, which start with 1, since the list index is used for zero.  To 
refer to a column in code, you start with zero for both columns and rows...

-- 
Daryl S


"Dirk Goldgar" wrote:

> "Daryl S" <DarylS@discussions.microsoft.com> wrote in message 
> news:637D3EBF-B7F5-4F85-B4BA-7E05B2CD721E@microsoft.com...
> > SF -
> >
> > The columns in a list box, combo box, or drop-down list box start with 1
> > (first column).   You can just use Me.lstContract.column(2) for the second
> > column.
> 
> 
> I'm sorry, but that is wrong.  The Columns collection is 0-based, so the 
> first column is .Column(0).
> 
> -- 
> Dirk Goldgar, MS Access MVP
> Access tips: www.datagnostics.com/tips.html
> 
> (please reply to the newsgroup)
> 
0
Utf
12/4/2009 4:08:02 PM
Reply:

Similar Artilces:

Changing rows by Columns
Hi, I have a query. I need to show the result of this query changing rows by columns in the table of my report. How I can to make it in SSRS 2005? Best regards and thanks!! Julio I would T-SQL , a new PIVOT command does that "julito" <julito@discussions.microsoft.com> wrote in message news:E79F47EB-504E-494B-AA4F-EFEEFF510A8D@microsoft.com... > Hi, > > I have a query. I need to show the result of this query changing rows by > columns in the table of my report. > > How I can to make it in SSRS 2005? > > Best regards and thank...

How to set the column title in a listbox from Excel
any help here? You can do it two ways. 1.) Include a header in your RowSource Range. 2.) You can put Lablels just above your ListBox to label your ListBox columns. Hope this helps! If so, let me know, click "YES" below. -- Cheers, Ryan "V Hoang" wrote: > any help here? If ColumnHeads is set to true in the properties window, then the header row should not be included in the RowSource or ListFill range. VBA will automatically include the row above the ListFill range as a header if the ColumnHeads property is set to true. "Ryan H&q...

Modify Outlook Default Columns for New Folder??
When I create a new folder to store e-mail, one of the default columns is the "Size" column. I prefer not to have this column in my folders. I know I can right click and remove this column. Is there a way to modify my settings so that this column will never appear when I create a new folder in Outlook? Tom View, Arrange by, if Ol2003], Current View, Define views... reset the view (usually Messages) and modify it. -- Diane Poremsky [MVP - Outlook] Author, Teach Yourself Outlook 2003 in 24 Hours Coauthor, OneNote 2003 for Windows (Visual QuickStart Guide) Author, Google and Othe...

Parsing thru columns to find the last number
I have six columns of data and am unsure how to get to the final replacement of an item. See, col A is the itemcode, then b,c,d,e,f contain item codes that have replaced the col a item. Not all items have been replaced five times, some none, some only two, in this case col b would be blank and or col C would be blank. My goal is to find the last item in the columns that were replaced and put it in a column on it's own. So the outcome will be colA is replaced by Col G. The data looks like this. A B C D E F G z k o p i So this was replaced four times and the end res...

Formula to find the last number of a column (lower cell)
I have a column with numbers. I want a formula that it will be finding the lower cell that has data. For example in column A i have numbers in cells A1, A2 and A3. In cell A10 i want a fotmula. With this formula will see in cell A10 the number that i have in cell A3. If i put a number in cell A4 i want that number to be shown in cell A10. Try the below in cell A10 =LOOKUP(10^10,A1:A9) -- Jacob (MVP - Excel) "yiannis5231" wrote: > I have a column with numbers. I want a formula that it will be finding the > lower cell that has data. For example in colu...

Column chart with 2 Y axis's
I have two Y axis, the secondary is 10x the primary in values. The 1 data series plotted against the secondary axis shows up right on top of the 4 data series plotted against the primary axis. Is there some way to avoid this, so all 5 data series appear side by side with no overlap? Thanks!!! Norm PS Excel 2002 & WIndows 2000 Pro Father Guido ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ I plan on living forever... so far, so good Plot the data series you want on the secondary axis not once but 5=20 times. Ensure all of them are on ...

Counting rows of blanks across certain columns
I have a survey whose answers were recorded in Excel. The answers for a particular question extend from Q6 to Z505. I need to count the people who did not answer the question (that is, the people, entered in rows 6 to 505 that left columns Q through Z blank). I'm not sure how to do this. Can someone offer a suggestion? Hi You can use a formula like this in Column AA =IF(COUNTA(Q6:Z6)=0,1,"") copy down till AA505 You can use a simple Sum formula now to count the empty ones =SUM(AA6:AA505) -- Regards Ron de Bruin http://www.rondebruin.nl "crossingboston" <...

calendar issues with column headings
I have users that display multipe calendars at once. We are using OL 2003 with Exchange server 2003. When they have 5 or more calendars open, the column heading gets truncated. This is not a problem except that the column header is being center justified instead of left justified. When this happens, the name of the calendar becomes unreadable due to the names being similar in the middle of the calendar name. I found a setting in the views to change this for email column headers, but not for calendars. In OL2007, the calendar column heading is left justified. Is there an easy way ...

Adding sums in rows and columns and colouring cells with conditions
Hi all, I have a long table where i need to add and colour individual cells based on 'days home' and 'days away'. The table is uploaded here https://www.yousendit.com/download/MnFqaUNBUzhoMlYzZUE9PQ In order to automate some of this i'd like to automate some, but preferably all aspects of this, such as: 1. automatically colour the cell orange for "home" and yellow for "away" 2. add separately in the home and away columns the number of days for each 3. add the rows for the alternate lines (ie days only, rates only) I want to do this without yet another...

Grouping columns
I have a spreadsheet where the columns of data are in logical groups. For example, I have 5 columns of data for the month of February, followed by the same 5 columns but for March etc. What I want to do is than when the user scrolls right or left the whole of one month moves and not part of it. is there some way to group the columns so that they will scroll as a unit? Jonathan Blitz AnyKey Limited Israel You can use one unused row, like row 1, and merge the 5 cells across for each month..........then use that row to do your scrolling....... Vaya con Dios, Chuck, CABGx3 "Jonatha...

how do you keep a column in date form
i'm making a spreedsheet in office excel, in column A I have a list of dates. I would type in 4/5 for an date and excel would automatic change the date to 4-Apr. I like this way, but when I got to cell 26, the change will not happen. I type in 4/5 and I get just the number 1 in the cell, for the rest of the cells down, can someone help me. Copy the cell that has the format you like and paste format it to the cells that you want to have the date format. "s2m2" <s2m2@discussions.microsoft.com> wrote in message news:F350F90F-24B9-4B79-BE39-20AB0414015D@microsoft.com......

Can you expand/collapse columns based on a reportitem/field values
I have a report that is driven by accounting periods. The columns are 1, 2, 3, Q1, 4, 5, 6, Q2...YTD. Currently when the report opens all that is shown is Q1, Q2, Q3, Q4, and YTD and the user can expand from there. What I want to happen is, if we are in Q2, I want columns 4,5,6, Q2 to be expanded. So the report should read Q1, 4,5,6, Q2, Q3, Q4, YTD. Is this possible? Thanks in advance Original Stealth, Certainly can. I created the following dataset: SELECT 'Q1' AS Expr1, 1 AS Expr2, 500 AS Expr3 UNION ALL SELECT 'Q1' AS Expr1, 2 AS Expr...

Command button
[Excel 2003] I have command buttons on the userform which access other userforms (which drive the spreadsheet data entry) I have a listbox on the userform displaying a number. I would like to enter code into the command button activations such that if the number in the listbox does not equal the number stored within the code of the command button then a mesage box is displayed and the command button does not activate its sub routines. Can anyone help? Thanks, Roger Something like this: Option Explicit Public Property Get MayProceed() As Boolean Const M...

Default Public View has records but columns are blank
A custom entity has a default list view but the entries in the list do not show any values. There are a number of lines in the list with an icon only. If I try to delete one the message says select an entry before attempting operation. I cannot select the lijne either. Have created many views before and never seen this. Other views are ok? Hi Steve, Try publishing the entity and see if this resolves the problem. HTH, Niths "Steve" wrote: > A custom entity has a default list view but the entries in the list do not > show any values. There are a number of lines in the...

HIDDEN COLUMNS #3
SOMEHOW I'VE HIDDEN COLUMNS A AND B, AND NOW I CAN'T UNHIDE THEM. HELP! Click on the header for column C, highlighting the entire column. Without releasing the mouse, drag until you're over the column of row headers (on my version of Excel, in Office 2003, I see the tool tip change to '3C'). Now you should be able to Format > Column > Unhide. "acp20770" wrote: > SOMEHOW I'VE HIDDEN COLUMNS A AND B, AND NOW I CAN'T UNHIDE THEM. HELP! If you select the sheet then go to window and unhide it will restore the Hidden windows. "acp20770&q...

Column A to change font color if column B is not empty
Hi, I'd like to have column A of a sheet to automatically turn to red font when a cell in column B is entered,ie, the Cell A3 will change from red to black when B3 is entered and B3 is a date. Can it be done? Thanks & Regards, Val Hi try: - select cells A3:A10 - goto 'Format - Conditional format' - enter the formula =$B3<>"" - choose a format -- Regards Frank Kabel Frankfurt, Germany dolphinv4 wrote: > Hi, > > I'd like to have column A of a sheet to automatically > turn to red font when a cell in column B is entered,ie, > the Cell ...

Adding and subtracting from a column.
I have a stock list with a "quantity" column. What I would like to do is add the new stock to the existing quantity column or subtract requisitioned items from the quantity column. I guess it is a "self totaling" column I need to make. As a separate exercise I would like to make a new column for orders. Insert a quantity on that column for any of the items ( rows) I want to order and then print it out... BUT I only want to print the rows that have quantities in that column ( i.e. the actual items I am ordering ). This column is not linked to the above column. Could an...

Sheet range reference
I have a workbook with a number of sheets, let's say named sheet01, sheet02 ......sheet10. These sheets are of the same structure and are representing some development in time. So now I would like to make a chart (or separate table) the where the X coordinate is the sheet number and the Y some cell on each of the sheets. Is this possible with a simple reference like the ranges within the same chart or do I really have to create a macro or do it by hand? Jens. Each series must reside on a single sheet. You can create a summary sheet which has something like: A1: =Sheet1!A1 A2: ...

Bridge or Up/Down floating column chart
Might anyone know of an example to a bridge or floating bar chart that I could download and learn from - I need to build a template in excel for lots of Power point slides. I have a book with a picture of one but no examples. Thanks for the time Try either of these tutorial pages: http://peltiertech.com/Excel/Charts/FloatingColumns.html http://peltiertech.com/Excel/Charts/Waterfall.html - Jon ------- Jon Peltier, Microsoft Excel MVP Peltier Technical Services Tutorials and Custom Solutions http://PeltierTech.com/ _______ TFrisch wrote: > Might anyone know of an example to a ...

Repeat values in column A a certain number of times depending on the value in column B
Imagine a set of data as set out below: Column A Column B Apples 24 Pears 36 Oranges 8 I want to poplulate a column (for exampel column A on a new sheet), where the values in column A will be repeated as many times as the value in column B Thus the first 24 rows will say Apples, the next 36 rows will Pears, Oranges. I need a formula that recogonizes that when it gets to row 25 that it should no longer need to copy Apples, but then switch to pears. This might sound like an unusual request but if I can grasp a way to do this I can create the table I need and populate the rest...

selecting the 2nd column of a combo box in a report?
I have a combo box that uses data from a table with the fields (setupid, physician setup, md_PIN). the bound column = 1. The physicians sign on using their name (signing_md) and PIN (signing_md_pin). thanks to advice from this website I have...If signing_md_pin.value = dlookup("md_pin". "[setup table]","[setupid] =" [signing_md] then ... in the event procedure. When I try to get the physician name on the report (signing_md) it returns the physician number (setupid) instead of the name. How do I get the 2nd column of the combo box to the report?Thank you....

How to succesfully sort column of formulas?
I am trying to sort a column of formulas that consist of cel references. Example: Column: Cell 1 holds: =D10 Cell 2 holds: =D11 Cell 3 holds: =D12 Data: D10=1 D11=2 D12=3 When I try to sort the column of formulas, the formulas change cel references to other cells and mess up the data. How can I sort a column of cells of which all of them contain formula and have the cells keep the references to the right place -- Message posted from http://www.ExcelForum.com Hi- If you write your formulae with absolute references rather tha relative references, you can sort them. Formulae should look ...

reference chain
Hello, I have a table filled with streets from which some were renamed one ore more times. Each street has a scode. If it was renamed is has an entry scodenew and status 'S', otherwise no scodenew and status 'G', this is the valid street name. I want to ask for any old street name, and want tot get the valid name, E.G. if I am asking for 'astrasse' or 'bstrasse' as well, I want to get 'cstrasse'. I guess this could be managed by a recursive CTE, but I dont know how. How would a CTE solution look like? Or is there another way for this kind ...

Excel not pasting the formula or reference
I am trying to take a worksheet "apple" and copy it to a new workbook "banana". It works for another worksheet but not this one. I am highlighting the whole worksheet and copying it and then opening the workbook sheet and clicking the corner box and selecting paste. When it works correctly the cell would look like this: cell from "apple" ='sheet1'!A2 then when it is pasted over to "banana" ='C:\Documents and Settings\Desktop\PERSONAL\[apple.xls]Sheet1'!A2 now when i paste it over it just pastes what the cell displays which...

Row amd column heading
I have received one excel file in which rows number (1,2...) and column name (A,B,...) are in some big font 18, or maybe more. I couldn't find option to make them standard. Thanks in advance, Emilija Hi Emilija, On you toolbar you should have a font box and next to it is the size of the font. Select the row and change the fontsize to 10 for instance. Help, Answer Wizard Change font size From the topics show, select the topic that matches "Change the font or font size" --- HTH, David McRitchie, Microsoft MVP - Excel [site changed Nov. 2001] My Excel Pages: http...