Gasman
Enthusiastic Amateur
- Local time
- Today, 12:40
- Joined
- Sep 21, 2011
- Messages
- 14,051
Ok, to avoid confusion, I created the sub below and then ran it.
The last set does not allow access to the ID field as no current record, but in this thread, that did not matter as we were adding a new record.
I created
The output was
The last set does not allow access to the ID field as no current record, but in this thread, that did not matter as we were adding a new record.
I created
Code:
Sub TestRecordset()
Dim db As Database
Dim rst As Recordset
Set db = CurrentDb
Set rst = db.OpenRecordset("transactions")
Debug.Print "Table with recordcount " & rst.RecordCount
Debug.Print "Table record ID " & rst!ID
rst.Close
Set rst = db.OpenRecordset("select * from transactions")
Debug.Print "Select from table with recordcount " & rst.RecordCount
Debug.Print "Select from table record ID " & rst!ID
rst.Close
Set rst = db.OpenRecordset("select * from transactions where ID = 0")
Debug.Print "Select from table ID = 0 with recordcount " & rst.RecordCount
'Debug.Print "Select from table ID = 0 record ID " & Nz(rst!ID, 0)
rst.Close
Set rst = Nothing
Set db = Nothing
End Sub
The output was
Code:
Table with recordcount 282
Table record ID 1
Select from table with recordcount 1
Select from table record ID 1
Select from table ID = 0 with recordcount 0