sql value in a text box

J

JKlein

I am trying to use this sql to return the number of records in a query and
show it in a text box.
It shows the text not the value! Any help would be appreciated.

Text23.Value = "SELECT Count(tbl_TempCalendarData.MeetingID) AS
CountOfMeetingID FROM tbl_TempCalendarData GROUP BY
tbl_TempCalendarData.meetingdate HAVING
(((tbl_TempCalendarData.meetingdate)=#5/28/2006#))"
 
D

Douglas J. Steele

Text23.Value = DCount("MeetingID", "tbl_TempCalendarData",
"meetingdate=#5/28/2006#")

Incidentally, there was no need for the GROUP BY in your original SQL. You
only need GROUP BY when the field is included in the SELECT part of the SQL:

SELECT Count(MeetingID) AS CountOfMeetingID
FROM tbl_TempCalendarData
WHERE meetingdate=#5/28/2006#"

(not that you can use SQL in the way you were trying)
 
J

JKlein

Douglas....thanks for the reply. This works great except when there are no
records to show. I need a way of returning a "0" if this is the case. I
have tried various ways but cant figure it out.
 
D

Douglas J Steele

That's odd. DCount returns 0 for me when there are no records that match,
even when there's no data in the table.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top