Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

evaluate string to reference form and change object source 1

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
0
0
GB
Hi,

I'm having difficulty getting the following to work
Code:
Eval("[forms]![contacts].[Page" & Current_Tab & "_Tab].SourceObject") = aTab(Me.TabCtl0)

I've tried different variations but just cannot work out the syntax.

Basically I have a form with a tab control, when the tab changes I want to dynamicaly change the source of the subform on the specific page.

Here is the full onchange function
Code:
Private Sub TabCtl0_Change()

    Dim aTab As Variant
    
    ReDim aTab(10)
    aTab(9) = "dbo_Business_Register subform"
    
    If (Current_Tab > 2) Then
        Eval ("[forms]![contacts].[Page" & Current_Tab & "_Tab].SourceObject = null")
    End If

    If (Me.TabCtl0 > 2) Then
        Current_Tab = Me.TabCtl0
        Eval("[forms]![contacts].[Page" & Current_Tab & "_Tab].SourceObject") = aTab(Me.TabCtl0)
    End If
    
End Sub

Can anyone help me get the syntax right please.

Thanks,
1DMF

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 



Hi,

Check out the Watch Window. Using it, you ought to be able to look at part or all of the expression you want to evaluate.

The question that pops up for me is, why are you not using the TEXT or VALUE or CAPTION property (not knowing your SourceObject), as the SourceObject has MANY PROPERTIES???

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
It's a subform and I want to change the SourceObject which is the form it references isn't it?

I looked up how to change the source of a subform and that's what I found out.

If I used
Code:
Me.Page9_Tab.SourceObject = "dbo_Business_Register subform"

It does exactly what I want it to do, however I'm trying to make it dynamic and evaluate a holding variable and concatenated string to equal the subform name.

I guess rather than trying to be clever I could always just use a case statement and hardcode the form changes.

I'd need to set all of them to blank to start with on each change as I wouldn't be using a global var to track what tab page the user was on.



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Me.Controls("Page" & Current_Tab & "_Tab").SourceObject = aTab(Me.TabCtl0)

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks PHV, but i didn't need it in the end.

I was being stupid , all I needed was a simple 'select case' statement and now the whole system has been re-written in 15 minutes!

It now runs 10 times faster as only the tab you are on loads the bound forms and data.

Then when you change tab it unloads the bound forms and data from the previous tab and loads up the current one.

So simple, yet extrememly powerful, much faster and less traffic on the network.

Now its time to put it in the field and wait for the bug reports [lol]



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"

Google Rank Extractor -> Perl beta with FusionCharts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top