parry
MrExcel MVP
- Joined
- Aug 20, 2002
- Messages
- 3,355
Hi, Im trying to understand some basic SQL. I have created a button on a form and the code to this is below. What I want to do is count the number of records in Table1 where the Played field is equal to true.
I did a normal query then looked at the SQL View and it had this...
SELECT Table1.Played
FROM Table1
WHERE (((Table1.Played)=True));
It always comes up with the answer 1 where it should be 50.
I have tried just counting the number of records in the table using the following code which worked so I must be doing something right Im just stuck on the select bit. Any ideas?
I did a normal query then looked at the SQL View and it had this...
SELECT Table1.Played
FROM Table1
WHERE (((Table1.Played)=True));
Code:
Private Sub Command125_Click()
Dim MyDb As Database, Rs As Recordset
Set MyDb = CurrentDb
Set Rs = MyDb.OpenRecordset("Select Table1.Played from Table1 where Table1.played =true")
MsgBox "There are " & Rs.RecordCount & " games that have been played"
End Sub
It always comes up with the answer 1 where it should be 50.
I have tried just counting the number of records in the table using the following code which worked so I must be doing something right Im just stuck on the select bit. Any ideas?
Code:
Private Sub Command125_Click()
Dim MyDb As Database, Rs As Recordset
Set MyDb = CurrentDb
Set Rs = MyDb.OpenRecordset("Table1")
MsgBox "There are " & Rs.RecordCount & " records in the table"
End Sub