UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Refer To Form Or Report Inside Subform Control, Access 2016    
 
   
Pilotwings_64
post Oct 17 2019, 01:32 PM
Post#1



Posts: 281
Joined: 20-August 10



I created a function that cycles through the source object of a subform control and changes the ColorThemeIndex value of all its controls’ relevant properties. It accepts an argument (sfc) for the subform control, and a byte value (ci) for the ColorThemeIndex.

Sometimes this source object of sfc is a form and sometimes it’s a report. The way I’m dealing with that is something like this:

CODE
Dim ctl as Control

If left(sfc.SourceObject, 7) = “Report.” Then
    For Each ctl In sfc.Report.Controls
        …
Else
        For Each ctl In sfc.Form.Controls
        …
End if


Is there any way I can combine the two so that one line works for either a report or form?
This post has been edited by Pilotwings_64: Oct 17 2019, 01:42 PM
Go to the top of the page
 
cheekybuddha
post Oct 17 2019, 01:42 PM
Post#2


UtterAccess VIP
Posts: 11,743
Joined: 6-December 03
From: Telegraph Hill


Perhaps not one line, but how about:
CODE
Dim ctl as Control, objSrc As Object

If left(sfc.SourceObject, 7) = “Report.” Then
    Set objSrc = sfc.Report
Else
    Set objSrc = sfc.form
End if
For Each ctl In objSrc
' ...
Next
Set objSrc = Nothing


hth,

d

--------------------


Regards,

David Marten
Go to the top of the page
 
Pilotwings_64
post Oct 30 2019, 01:10 PM
Post#3



Posts: 281
Joined: 20-August 10



Thanks! That worked.
Go to the top of the page
 
cheekybuddha
post Oct 30 2019, 01:20 PM
Post#4


UtterAccess VIP
Posts: 11,743
Joined: 6-December 03
From: Telegraph Hill


thumbup.gif

--------------------


Regards,

David Marten
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    20th November 2019 - 11:03 PM