- For individual users
- Instant access to solutions
- Ask your tech questions
- Start your 30-day Free Trial
Main Topics
Browse All TopicsHello all. I'm hoping this is a simple question and I'm just overlooking something.
I spend a great deal of time building reports in Excel by drawing out data from Access. I do this using VBA within Excel, typically using DAO to connect to Access.
In many instances, to determine whether a report needs to be run, I'll create a DAO recordset and check the Recordcount (>0 = run the report). From within Access (in other projects) I've used the various D-functions, and was wondering about doing the same here.
i.e., instead of creating a recordset and checking the Recordcount, use a DCount against the Access query or table to determine if there are any records to process. If so, go ahead and create the recordset. If not, skip to next possibly report criteria (w/o creating a recordset).
At this point, I'm a little unsure of what the syntax would be as I'm writing this within the Excel VBE, not the Access VBE. What arguments would I use in the (say) DCount to reference an Access object from Excel?
Let's throw out some sample objects: Access table = "Records", criteria (say) "where FirstName = "Bob" ".
Building the recordset from this is easy, and is how I go:
set rs = db.openrecordset("SELECT * FROM [Records] WHERE [FirstName] = 'Bob'")
myCount = rs.recordcount
What would the DCount look like? (Remember, we're in Excel VBA here, trying to reference the Access db's objects)...
Thanks much. This should be quick and easy for me to test/check, so any solutions should receive a repsonse pretty quickly.
This question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership