Hello again, i have a table in an Access database holding entries from a diary. Each entry has a Subject, the Entry itself and the Username (The author of the entry).
I want to do a search of the entire entry table, for one specific user, for example the user would be "Jim", and in VB i would use the .RecordCount to count the number of records in that query, thus showing how many entries the user has made.
This current code will only show the user "Ben" to have 1 entry, where he really has 3? Any ideas.?
The RecordCount might not work in all cases it all depends on which type of cursor you're using. Sometimes you also need to move to the last position in the recordset before this property shows the correct number of records. A better approach might be to use the COUNT SQL statement.
VB Code:
Sqltxt = "SELECT COUNT(Entry.UserName) AS EntryCount WHERE Entry.UserName = '" & UniUsername & "'"
Set MySearch = MyDatabase.OpenRecordset(Sqltxt)
lblEntry.Caption = "You have " & MySearch("EntryCount") & " entries"
If you don't want to use that try to MoveLast and then MoveFirst in the recordset before you read the RecordCount.