With help of the embedded access vb editor i\'ve written a small code to analyse the field values of my database, and want to finally view the recordsets in a table inside t
Here is the basic recipe:
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM myTable")
Know that you are using Jet Data Access Objects (DAO) with Access - google that for details.
Expression (rs.BOF and rs.EOF) = True indicates there were no rows.
Use rs.MoveFirst, rs.MoveNext to go to the first and next rows. Test rs.EOF after rs.MoveNext; when True, last row was already processed.
rs(FieldName) returns the value of the column named FieldName (a string expression).
rs(1) returns the value of the second column.
When done, rs.Close.
There is no way to hand Access the RecordSet and have it displayed in a Datasheet view. Instead, you will have to create a QueryDef object and use it to perform the query and display the Datasheet view of the results:
Dim qd As QueryDef
On Error Resume Next
CurrentDb.QueryDefs.Delete "temp"
On Error GoTo 0
Set qd = db.CreateQueryDef("temp", "SELECT * FROM myTable")
DoCmd.OpenQuery "temp", acViewNormal, acEdit