Solved

Using Dcount for Access table from a VB.Net form

Posted on 2010-08-14
6
914 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
  • 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

777 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