Getting 'Run-time scenarios 91' When Trying to Access a Collection in VBA for Access
I can't seem to get I'm sure I'm missing something obvious here, but I've searched everywhere and can't find a clear answer. I'm working with a frustrating scenario while trying to iterate through a collection of records in an Access database using VBA. My intention is to loop through all the records in a table and access specific fields for further processing. However, I keep getting 'Run-time behavior 91: Object variable or With block variable not set' when I attempt to access fields in the records. Hereโs the code snippet that Iโm using: ```vba Dim db As DAO.Database Dim rst As DAO.Recordset Set db = CurrentDb() Set rst = db.OpenRecordset("SELECT * FROM MyTable") Do While Not rst.EOF Debug.Print rst!FieldName rst.MoveNext Loop rst.Close Set rst = Nothing Set db = Nothing ``` Iโve checked to ensure that 'Microsoft DAO 3.6 Object Library' is referenced in my VBA environment. The table name is correct, and I can confirm that there are records in 'MyTable'. Despite these checks, the behavior continues when I try to access the fields within the loop. Additionally, Iโve tried initializing the recordset differently by using `Set rst = db.OpenRecordset("MyTable")` directly, but I still run into the same behavior when attempting to access the fields. Iโm running Access 2016, and it seems as though the recordset isnโt being populated as expected. Any ideas on what could be causing this scenario or how I might troubleshoot it further? For context: I'm using Vba on Linux. Is there a better approach? I'm working on a web app that needs to handle this. I'm using Vba stable in this project. What am I doing wrong?