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

x
?
Solved

Select query in VB

Posted on 1999-07-23
8
Medium Priority
?
156 Views
Last Modified: 2010-04-30
I have written a select query that finds a count, how can I display this count in a message box to inform the user?
0
Comment
Question by:darwin072398
[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
8 Comments
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1527003
rs.open "SELECT COUNT(*) AS C1 FROM Table1 WHERE ID>100"
msgbox rs!C1
0
 

Author Comment

by:darwin072398
ID: 1527004
Is rs a collection? please be more specific.
0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1527005
rs is the recordset you execute the query on. You didn't specify the data access method you are using, so that was a general example. Anyway, no matter what you are using, execute that statement, and you'll get the results.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:darwin072398
ID: 1527006
When dim the rs as a recordset I still get error messages. rs.open will not work, nor will rs.openrecordset
0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1527007
What data access method are you using?
DAO/RDO/ADO?
0
 
LVL 8

Expert Comment

by:vettranger
ID: 1527008
Please paste your query as a comment here.
0
 
LVL 6

Accepted Solution

by:
setiawan earned 150 total points
ID: 1527009
Suppose that you have access database : database1.mdb
and in database1.mdb has table employee

dim mydb as database
dim rs as recordset

set mydb = opendatabase(app.path & "database1.mdb")
set rs = mydb.openrecordset("select count(*) as x from [table employee] where id > 100", dbopensnapshot, dbreadonly)
msgbox x

0
 
LVL 8

Expert Comment

by:MikeP090797
ID: 1527010
should be msgbox rs!x
0

Featured Post

Technology Partners: 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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

715 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