Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Message Box to Display a Record Count

Status
Not open for further replies.

dcrosier

Instructor
Mar 17, 2000
51
US
I would like to create a Message Box that will display the results to two seperate queries. Could someone help me with the syntex? Both Queries are Counts of records based on criteria.

I will be attaching the msgbox to the OnOpen Event of the Switchboard.

msgbox ("Total Items Checked Out: qryResult1 Total Items Late: qryResult2", vbOkOnly, "Late Equipment")

The above is where I am thinking, I just need help on passing the query result into the message box.

Thanks.
Dawn
 
This will do what you want:

Dim db As Database
Dim rstCheckOut As Recordset, rstLate As Recordset
Dim intCheckTtl As Integer, intLateTtl As Integer

Set db = CurrentDb

Set rstCheckOut = db.OpenRecordset("qry Checked Out") 'query name in quotes
intCheckTtl = rstCheckOut.Fields("TotalOut") 'field name in query
rstCheckOut.Close

Set rstLate = db.OpenRecordset("qry Late Count") 'query name in quotes
intLateTtl = rstLate.Fields("TotalLate") 'field name in query
rstLate.Close

MsgBox ("Total Items Checked Out: " & intLateTtl & vbCrLf & vbCrLf & "Total Items Late: " & intLateTtl), vbOKOnly, "Late Equipment"

------------------------------
Note: Dawn, you should add Error handling, etc.
 
If you have a field that is unique to each record, you could use COUNT [field name], for instance, I have this in a database,and it counts the number of last names, since these are unique for my database.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top