Solved

Using Dcount for Access table from a VB.Net form

Posted on 2010-08-14
6
885 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 119

Accepted Solution

by:
Rey Obrero 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now