Solved

Using Dcount for Access table from a VB.Net form

Posted on 2010-08-14
6
978 Views
Last Modified: 2013-11-28
I am using a VB.Net form and need to count the number of cars (of a particular make) with black color saved in an access table.

The  table is called tblAutos the car make column is called CarMake the Color column stores the color of each car.

Is it possible to use some thing like Dcount to accomplish this from a VB.Net form.
A short example would be appreciated.

Thanks
0
Comment
Question by:adamtrask
[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
  • 3
  • 2
6 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 250 total points
ID: 33438512
dcount() function syntax is

dcount("*","tblAutos","[color]='Black'")  'for all black cars

dcount("*","tblAutos","[color]='Black' and [CarMake]='Honda'")  'for all black Honda cars
0
 

Author Comment

by:adamtrask
ID: 33438885
Thank you capricorn1, but I know the dcount syntax. My question is how to use it from a VB.Net form.

0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 250 total points
ID: 33439059
Dcount is no more that a "VBA Query"

You can get the same result from a query like this:

Select Count([EmpID])
FROM tblEmployees
WHERE State='NY'

So you can run the SQL and return the result to your form.

FWIW, the Dcount() equivalent would be:
   Dcount("EmpID","tblEmployees", "State='NY'")

;-)

JeffCoachman
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 33439062
Dcount is no more that a "VBA Query"-->Dcount is no more *than* a "VBA Query"
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 33439095
<Optional>
See here for info on assigning a SQL query result, to a form Variable:
http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_22951209.html
0
 

Author Closing Comment

by:adamtrask
ID: 33441725
Thanks to both of you
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
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…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Suggested Courses

623 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