Solved

Using Dcount for Access table from a VB.Net form

Posted on 2010-08-14
6
944 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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access syntax 1 34
how to remove error in database 6 37
Copying from a network share 3 26
ms/access programmatically get a list of fils and folders 3 25
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

730 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