Doing some volunteer work for a the Kidney Foundation.
Working on a small Access database.
I'm an old Foxpro programmer.
MS Access is not my thing, but volunteering is a good thing.
Would someone show me the means to have a second recordset associated with the existing form, please.
Below is my first effort:
Code:
Option Compare Database
Private cn As ADODB.Connection
Private rstCallers As Recordset
________________________________________________
Public Sub initRecordSet()
Dim rs As ADODB.Recordset
Set cn = CurrentProject.Connection
Set rs = New ADODB.Recordset
With rs
Set .ActiveConnection = cn
.Source = "SELECT * FROM ClientCaller"
.LockType = adLockOptimistic
.CursorType = adOpenKeyset
.Open
End With
Set Me.Recordset = rs
' Here's a second reordset to be referenced as a property of the current form.
' This routine is being called in the form's Load event.
Set rstCallers = CurrentDb.OpenRecordset("select clientId from ClientCaller group by clientId", dbOpenSnapshot)
End Sub
I noticed, once this routine is run, in the Watches screen the form's property, Recordset, is of type, Object/Recordset.
The 'custom' property, rstCallers, is of type, Recordset/Recordset2
Is this because of the use of OpenRecordset()?
Should it not be of the type, Object/Recordset?
I'm getting an error when I later try to reference the property.
Must be a syntax error, I'm thinking.
Again, MS Access bit of a learning curve for me.
The error: Run-time error '2465': Application-defined or object-defined error.
Code:
Private Sub cmdStaff_check()
Dim frm As Form
Set frm = Forms!frmEntry
If frm.rstCallers.EOF Then ' <-- Run-time error '2465':
:
:
End Sub
What's the cause and the cure of this error?
Much thanks.
Drawn