Recordsetclone gives empty recordset

%3CLINGO-SUB%20id%3D%22lingo-sub-3178237%22%20slang%3D%22en-US%22%3ERecordsetclone%20gives%20empty%20recordset%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3178237%22%20slang%3D%22en-US%22%3E%3CP%3EI%20have%20code%20below%20which%20is%20in%20the%20Form-Load.%20According%20help%2C%20the%20Form-Load-event%20is%20triggered%20after%20the%20records%20have%20been%20loaded.%26nbsp%3B%20However%2C%20the%20Set%20rs%20%3D%20Me.Recordset%20retrieves%20no%20records%20at%20all.%20I%20also%20tried%20with%20Set%20rs%20%3D%20Me.Recordsetclone%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20I%20go%20in%20debug%20mode%20through%20the%20code%2C%20line%2016%20is%20skipped.%3C%2FP%3E%3CP%3EHowever%2C%20the%20form%20does%20show%20the%20expected%20records.%3C%2FP%3E%3CP%3ESo%20why%20is%20my%20RS-recordset%20empty%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-visual-basic%22%3E%3CCODE%3EPrivate%20Sub%20Form_Load()%0ADim%20strSplit()%20As%20String%0ADim%20rs%20As%20Recordset%0ADim%20intInSpec%20As%20Integer%0A%0AIf%20Not%20IsNull(Parent.OpenArgs)%20Then%0AstrSplit%20%3D%20Split(Parent.OpenArgs%2C%20%22%E2%82%AC%E2%82%AC%E2%82%AC%E2%82%AC%E2%82%AC%22)%0AMe.Filter%20%3D%20strSplit(1)%0AMe.FilterOn%20%3D%20True%0AEnd%20If%0AMe.Form.Section(2).Visible%20%3D%20False%0A%0AintInSpec%20%3D%200%0ASet%20rs%20%3D%20Me.Recordset%0AWhile%20Not%20rs.BOF%20And%20Not%20rs.EOF%0Ars.MoveNext%0AWend%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3178237%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Eaccess%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
New Contributor

I have code below which is in the Form-Load. According help, the Form-Load-event is triggered after the records have been loaded.  However, the Set rs = Me.Recordset retrieves no records at all. I also tried with Set rs = Me.Recordsetclone

 

If I go in debug mode through the code, line 16 is skipped.

However, the form does show the expected records.

So why is my RS-recordset empty?

 

 

Private Sub Form_Load()
Dim strSplit() As String
Dim rs As Recordset
Dim intInSpec As Integer

If Not IsNull(Parent.OpenArgs) Then
strSplit = Split(Parent.OpenArgs, "€€€€€")
Me.Filter = strSplit(1)
Me.FilterOn = True
End If
Me.Form.Section(2).Visible = False

intInSpec = 0
Set rs = Me.Recordset
While Not rs.BOF And Not rs.EOF
rs.MoveNext
Wend
End Sub

 

 

2 Replies
maybe got to do with your OpenArgs, what is the value passed?
you need a Fieldname to filter it.
and I believe this is from the Load event of the subform?

strSplit = Split(Me.Parent.OpenArgs, "€€€€€")
Me.Filter = "theField = '" & strSplit & "'"
Me.FilterOn = True

@arnel_gp 

It's not related with the arguments.  The filter works as expected and the expected records are shown.

 

It's indeed true the code is in the subform.