By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,606 Members | 1,757 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,606 IT Pros & Developers. It's quick & easy.

Indirect String Reference To Subform

P: n/a
Howdy,

I'm trying to apply color schemes to forms and subforms. I'm using a
global function to change the colors/fonts of controls. Right now it
correctly loops over the controls in the main form, what I want is
recursive behavior to format the subforms.

Here's a sketch:

Function ApplyColorScheme(strFormName As String)
Dim actFrm As Form
Dim ctl As Control
Set actFrm = Forms(strFormName)

For Each ctl In actFrm.Controls
With ctl
Select Case .ControlType
'Change a bunch of things
Case acSubform
ApplyColorScheme ("[Forms]![" & strFormName & "]![" &
..Name & "].Form")
End Select
End With
Next ctl
End Function

Which will run over all the controls properly in the main form but die
when trying to load up the subform as (for example)
"[Forms]![frmMain]![frmSub].Form" saying "Microsoft Access Can't Find
the Form"

The main problem seems to be, while this statement works:
tmpString = "frmMain"
Set actFrm = Forms(tmpString)

I cannot get this one to
tmpString = "frmMain!frmSub.Form"
Set actFrm = Forms(tmpString)

nor I can figure out how to use the string as an indirect reference:
Set actFrm = [Forms]![frmMain]![frmSub].Form 'works

tmpString = "[Forms]![frmMain]![frmSub].Form"
Set actFrm = tmpString 'doesn't work

Any help would be very much appreaciated
Sam Phillips
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Figured it out. Try looking here if you have the same problem.

http://www2.usenetarchive.org/Dir8/File983.html

Sam
Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.