Aeristan
Registered User.
- Local time
- Yesterday, 22:10
- Joined
- Mar 29, 2019
- Messages
- 33
Good morning. I'm new to the forums, and I'd be so grateful if I could get some help. I do my best to research all the questions already answered, but this one has me baffled. (I am using Microsoft Office 365 ProPlus, so, I think it's Access 2016.)
I am working with a Form, form_CHARACTER, which is bound to a table named CHARACTER. I am trying to work with Me.Recordset in the event handlers, to do what seems to be simple tasks. There must be an easy way that I have overlooked.
Upon opening this Form, I want to set the current record to a specific Character, according to their name.
Here is the location of the error: (I have stripped out things like VbCrLf and vbTab, to make the code more readable)
Here is what I get in the Immediate window:
...and then the code fails at the last line with the following error message:
I am not finding that to be true. When I dim a variable as DAO., the auto-complete feature includes Recordset and Recordsets properties, but not Recordset2. A type mismatch error occurs if I try to refer to this Recordset as a DAO.Recordset object. Then, however, I have the following subroutine:
Which fails with the following message:
That part really confuses me, because I thought that all Object types in VBA had Name and Type properties.
A couple of things:
1) I'm using a DAO Recordset... or at least, I think I am...??? I disambiguate this in my code using the DAO reference, but I don't know how to set - or check - the default Recordset type of the Form itself.
2) The CHARACTER table does not contain any multi-valued fields. I double-checked. There is another table, ITEM, in my database that does contain one such field, but that table is not referenced in any way from this form.
3) I am certain that it didn't always do this. I have gotten this form to work and have spent a lot of time working with it and it's subforms. The problem started a couple weeks ago. However, as I go back through my older backups, I am unable to find any files within the last few months which aren't giving the same error.
My goal: to get the Recordset2 object to show the same properties and methods as the Recordset object, like the docs say that it should, OR to coerce a Recordset2 object into becoming a "normal" Recordset object.
Thoughts?
I am working with a Form, form_CHARACTER, which is bound to a table named CHARACTER. I am trying to work with Me.Recordset in the event handlers, to do what seems to be simple tasks. There must be an easy way that I have overlooked.
Upon opening this Form, I want to set the current record to a specific Character, according to their name.
Here is the location of the error: (I have stripped out things like VbCrLf and vbTab, to make the code more readable)
Code:
Private Sub Form_Open(Cancel As Integer)
Debug.Print ("form_CHARACTER: form Open event ( Character = " & Me.ID & " """ & Me!Name & """ )")
Debug.Print ("TypeName(Me.Recordset) = " & TypeName(Me.Recordset) & " Me.Recordset.Name = " & Me.Recordset.Name)
...
Me.Recordset.FindFirst ("[Name] = ""Raven"" ")
End Sub
Here is what I get in the Immediate window:
Code:
form_CHARACTER: form Open event ( Character = 4 "Sarjenka" )
TypeName(Me.Recordset) = Recordset2 Me.Recordset.Name = CHARACTER
...and then the code fails at the last line with the following error message:
Method 'FindFirst' of object 'Recordset2' failed
The TypeName of the Recordset is coming back as Recordset2. I did my research of course, and I see that Recordset2 is listed as a member of DAO. The purpose of this object type is to accommodate multi-value fields and other special situations. The docs clearly state, however, that "a Recordset2 object contains all of the same properties and methods as the Recordset object. The Recordset2 object contains a new property, ParentRecordset, that support multi-valued field types."
I am not finding that to be true. When I dim a variable as DAO., the auto-complete feature includes Recordset and Recordsets properties, but not Recordset2. A type mismatch error occurs if I try to refer to this Recordset as a DAO.Recordset object. Then, however, I have the following subroutine:
Code:
Public Sub debug_Recordset (rst As Object)
Debug.Print ("--> debug_Recordset(" & rst.Name & ") rst.Type = " & rst.Type & " TypeName(rst) = " & TypeName(rst) )
End Sub
Which fails with the following message:
Run-time error 438: Object doesn't support this property or method
That part really confuses me, because I thought that all Object types in VBA had Name and Type properties.
A couple of things:
1) I'm using a DAO Recordset... or at least, I think I am...??? I disambiguate this in my code using the DAO reference, but I don't know how to set - or check - the default Recordset type of the Form itself.
Here is my list of references, in order:
Visual Basic for Applications
Microsoft Access 16.0 Object Library
Microsoft DAO 3.6 Object Library
OLE Automation
Visual Basic for Applications
Microsoft Access 16.0 Object Library
Microsoft DAO 3.6 Object Library
OLE Automation
2) The CHARACTER table does not contain any multi-valued fields. I double-checked. There is another table, ITEM, in my database that does contain one such field, but that table is not referenced in any way from this form.
3) I am certain that it didn't always do this. I have gotten this form to work and have spent a lot of time working with it and it's subforms. The problem started a couple weeks ago. However, as I go back through my older backups, I am unable to find any files within the last few months which aren't giving the same error.
My goal: to get the Recordset2 object to show the same properties and methods as the Recordset object, like the docs say that it should, OR to coerce a Recordset2 object into becoming a "normal" Recordset object.
Thoughts?