Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using Dcount for Access table from a VB.Net form

Posted on 2010-08-14
6
Medium Priority
?
1,008 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 1000 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 1000 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

688 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