How to display recordset in datasheet view

  • Thread starter Thread starter Rick
  • Start date Start date
R

Rick

For testing purposes I would like to see a datasheet of the records returned
from a select query. I am using Access2000, DAO.
For example, the following:
strsql = "SELECT Clients.ClientID, Clients.RegistrationDate,
Clients.BabyActualDate, Clients.Father" _
& " FROM Clients" _
& " WHERE (((Clients.RegistrationDate)<" & dteFYStart & "));"
Set rstClients = dbsBITO.OpenRecordset(strsql)

Thank you for your advice.
Rick
 
Rick said:
For testing purposes I would like to see a datasheet of the records returned
from a select query. I am using Access2000, DAO.
For example, the following:
strsql = "SELECT Clients.ClientID, Clients.RegistrationDate,
Clients.BabyActualDate, Clients.Father" _
& " FROM Clients" _
& " WHERE (((Clients.RegistrationDate)<" & dteFYStart & "));"
Set rstClients = dbsBITO.OpenRecordset(strsql)

If it's just for your own testing add a line ...

Debug.Print strsql

....after assigning the string. Then you can copy the assembled SQL from the debug
window into a new query and see if it works as expected.
 
Thank you Rick ...

Rick Brandt said:
If it's just for your own testing add a line ...

Debug.Print strsql

...after assigning the string. Then you can copy the assembled SQL from the debug
window into a new query and see if it works as expected.
 
For example, the following:
strsql = "SELECT ClientID, RegistrationDate, " & _
" BabyActualDate, Father " & _
"FROM Clients" & _
"WHERE RegistrationDate<" &
Format(dteFYStart, "\#yyyy\-mm\-dd\#") & ";"

' Create a qerydef to hold it
' Actually, making it a parameter query would make the whole
' lot a bunch easier...
Set qdf = dbsBITO.CreateQueryDef("rnsTemp", strSQL)

' show it for debugging
DoCmd.OpenQueryDef "rnsTemp"

' Ask the user if it looks right: but out if it doesn't
If MsgBox("OK???",vbYesNo) <> vbYes then
Exit Sub
End If

' Okay, now open it as a recordset
Set rstClients = dbsBITO.Querydefs("rnsTemp").OpenRecordset _
dbOpenSnapshot, dbForwardOnly


' other stuff here, and then don't forget to
dbsBITO.QueryDefs.Delete "rnsTemp"


Hope that helps


Tim F
 
Back
Top