Run time error 2467 - Using recordset to populate rowsources

A

Alan

Please help
I may be way of the mark with what I am trying to do here

I have a Form with a tab control and 10 pages. embedded on each page is a
subform which I populate from a single table and filter on a specific column.

I am trying to be smart and reduce the code I use by placing a reference to
each page and its associated sql in another table which I call via the
recordset thus

Public Sub UpdatePageDetail_New()

Dim rstRDTDetail As Recordset
Dim strPageName As String
Dim strSQL As String

Set rstRDTDetail = CurrentDb.OpenRecordset("SELECT tblSQL.* FROM tblSQL
WHERE (((tblSQL.DATASET)='RDTDetail')) ORDER BY tblSQL.Type", dbOpenDynaset)
With rstRDTDetail
.MoveFirst
While rstRDTDetail.EOF = False
strPageName = .Fields("Type")
strSQL = .Fields("ExecutableSQL")

Me.TabCtl2.Pages(strPageName).Controls!
frmRDTUpdate.Form.recordsource = strSQL

.MoveNext
Wend
End With
End Sub

The first page works fine, but when it moves to the second page I get the
Runtime Error 2467 'The expression you have entered refers to an object that
is closed or doesnot exist'

Any pointers would be appreciated. I can write the page of code and call the
recordsource 10 times, however I am trying to use this method to update the
form height and include/exclude scrollbars dependent on the number of records
returned

Any help would be gratefully appreciated
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top