Dreamweaver
Well-known member
- Local time
- Today, 23:18
- Joined
- Nov 28, 2005
- Messages
- 2,466
Been trying to get a Recordcount From A SQL String which works when Assigned as a RecordSource
The Query is made up of the following items
StrWhere = "[ArtistID]=1123" Just example
Qry = "QryMediaPlayer" This is the query assigned to the forms recordsource
I have tried running a db.openrecordset("SELECT * FROM " & Qry & " WHERE " & StrWhere, dbopensnapshot)
Which gives be an error expected 1
So Started looking at QueryDefs Which I havent used much at all
Tried below which didnt work in that is always said there were no records
I have tried if different ways but still get the expected 1 error except for above code
This has to be one of them silly mistakes but I can't see it.
many thanks mick
The Query is made up of the following items
StrWhere = "[ArtistID]=1123" Just example
Qry = "QryMediaPlayer" This is the query assigned to the forms recordsource
I have tried running a db.openrecordset("SELECT * FROM " & Qry & " WHERE " & StrWhere, dbopensnapshot)
Which gives be an error expected 1
So Started looking at QueryDefs Which I havent used much at all
QueryDef.ReturnsRecords property (DAO)
Office developer client VBA reference documentation
docs.microsoft.com
Tried below which didnt work in that is always said there were no records
Code:
'Test For Records
'Set R = CurrentDb.CreateQueryDef("")
'R.SQL = "SELECT * FROM " & Qry & " WHERE " & StrWhere
'Set Rt = R.OpenRecordset()
' If Rt.RecordCount < 1 Then
' MsgBox "No Records Found For Your Selection", vbInformation + vbOKOnly, "No Records"
' R.Close
' Set R = Nothing
' Exit Sub
'End If
I have tried if different ways but still get the expected 1 error except for above code
This has to be one of them silly mistakes but I can't see it.
many thanks mick