Hi,
I have a form which has a list of different table names and another list of tabs. When you select a table name and a tab and then click on a button, the following code is executed:
This code works completely in Access 2003 but in 2010 the majority of the forms work but there are a few that don't.
For the forms that work, the Sourceobject property is set in less than a second whilst for the ones that do not work, it takes a good few seconds. Once that is done, when attempting to set the record source, i get the following error:
"The expression you entered refers to an object that is either closed or doesn't exist."
All of the tables are in the same database and i have tried creating new subforms linked to the same tables that fail, and these new subforms also fail.
Does anyone have any ideas where i could be going wrong?
I have a form which has a list of different table names and another list of tabs. When you select a table name and a tab and then click on a button, the following code is executed:
Code:
Dim objSubform As Object
Select Case strTabName
Case "Tab 1"
Set objSubform = Me.tabTableData.Pages(0).Controls(0)
intPageIndex = 0
Case "Tab 2"
Set objSubform = Me.tabTableData.Pages(1).Controls(0)
intPageIndex = 1
Case "Tab 3"
Set objSubform = Me.tabTableData.Pages(2).Controls(0)
intPageIndex = 2
Case "Tab 4"
Set objSubform = Me.tabTableData.Pages(3).Controls(0)
intPageIndex = 3
End Select
'Make Visible False to load data then to show
objSubform.Visible = False
mstrTableName = Me.lstDBTable.Value
'Reload Subform Query
objSubform.SourceObject = mstrTableName & " subform"
MsgBox objSubform.SourceObject
objSubform.Form.RecordSource = "SELECT * FROM " & mstrTableName
MsgBox objSubform.Form.RecordSource
objSubform.Requery
For the forms that work, the Sourceobject property is set in less than a second whilst for the ones that do not work, it takes a good few seconds. Once that is done, when attempting to set the record source, i get the following error:
"The expression you entered refers to an object that is either closed or doesn't exist."
All of the tables are in the same database and i have tried creating new subforms linked to the same tables that fail, and these new subforms also fail.
Does anyone have any ideas where i could be going wrong?
Comment