Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

need to know total number of items in the listbox and pass the value to an integer

Posted on 2006-10-25
13
Medium Priority
?
286 Views
Last Modified: 2008-02-01
I am designing a Form application in Access 2003.

I have a listbox containing data populated on basis of a selection in a combo box. I need to pass the rowcount of the listbox to an integer variable for furthur process. my combo box contains Date, my list box returns customer names for a Date selected.

I thought about two different approaches, but not successful yet.

1. I want to Dim ListControl as Control, try to use ListCount.
2. I tried to use Dcount function which needs taking the value of selection of the combo box as criteria in the function. I can write a query as expression to get same records as those populated in the list box.
Dcount("customer", "qry", "orderdate = Form!frm_master!cbo_orderDate"), my problem is that my criteria code is not right.

Any ideas? Thanks
0
Comment
Question by:jc50967w
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
13 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 17804358
dim x
x=me.listboxname.listindex
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 17804361
dim x
x=me.listboxname.listcount
0
 
LVL 65

Accepted Solution

by:
rockiroads earned 1000 total points
ID: 17804364
dim iCnt as integer

iCnt = Me.mylistbox.ListCount

msgbox "Number of items = " & iCnt
0
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
LVL 66

Expert Comment

by:Jim Horn
ID: 17804366
{no points please}

dim x as Integer
x=me.listboxname.listcount
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17804391
And using DCOUNT

If within the sama form, just do this

Dcount("customer", "qry", "orderdate = #" & Me.cbo_OrderDate & "#")

otherwise
Dcount("customer", "qry", "orderdate = #" & Form!frm_master!cbo_orderDate & "#")

0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17804400
And yet summat else, which I forgot to post

If your combo has 3 columns say, selecting the value (bounded column) may not be the one u need
therefore u can specify what column u want

col 0 is 1st column of data
col 1 is 2nd, etc

Dcount("customer", "qry", "orderdate = #" & Me.cbo_OrderDate.Colum(0) & "#")
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17804411
U may perhaps need to wrap OrderDate with CDATE but I think u should be ok

Im off home now, see ya all
0
 

Author Comment

by:jc50967w
ID: 17804698
Rockiroads, my combo box only has one column. The filed name OrderDate is just example name I used to discribe in this case. My real database, tables and fields are with very complicated business concept, and hard to post them in few lines. Then I use customer and their order as example case in here.

Thank you everyone.
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 17804772

as posted above

dim x
x=me.listboxname.listcount

is enough to get the number of items from the listbox

if you want to use dcount, try this

Dcount("customer", "qry", "cdate(format([orderdate],'mm/dd/yyy')) = #" & cdate(Format(Form!frm_master!cbo_orderDate,'mm/dd/yyy')) &"#"),
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 1000 total points
ID: 17804779
sorry

if you want to use dcount, try this

Dcount("customer", "qry", "cdate(format([orderdate],'mm/dd/yyyy')) = #" & cdate(Format(Form!frm_master!cbo_orderDate,'mm/dd/yyyy')) &"#")
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 17806357
ok jc50967w, where are we at this

you now know how to get a listcount and Ive told you about the error you had in your dcount

I mentioned the multicolumn just in case, but its not a problem now since u only have the one column.
Did the correction to the DCOUNT work? (after u change it to your fields that is)

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

597 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question