Solved On activate code - affecting all records instead of just one.

Chief

Registered User.
Local time
Yesterday, 17:08
Joined
Feb 22, 2012
Messages
156
Hello,
I have some reports that I have coded to do certain things, however it is affecting all records and not just the relevant record according to criteria.

Here is the code:

Code:
Private Sub Report_Activate()
    If ChkSubstrates = True Then
        ChkSubstrates.Visible = True
        ChkTemplates.Visible = True
        LblCutSubsTemps.Visible = True
    ElseIf ChkTemplates = True Then
        ChkSubstrates.Visible = True
        ChkTemplates.Visible = True
        LblCutSubsTemps.Visible = True
    Else
        ChkSubstrates.Visible = False
        ChkTemplates.Visible = False
        LblCutSubsTemps.Visible = False
    End If
End Sub

Here is the result of the reports: This one I know that some of the entries do have "templates" and or "Substrates" (But nothing showing)

1637285864279.png


This is another:

1637286019825.png


Not sure If I can code it to make these visible per entry?

Thank you
 
if the report is in "report" view, it will behave just like a continuous form.
have you tried using Conditional format? changing the color to "white" to hide
the control.
 
if the report is in "report" view, it will behave just like a continuous form.
have you tried using Conditional format? changing the color to "white" to hide
the control.
Hey mate,
Yes using Print Preview and printing the report.
I cant condition format the check boxes, and cant conditional format a label. (I can change the label to an unbound text box)

Might have to use your suggestion and conditional format the text and just have the check boxes always visible.

thanks
 
if using Print Preview, use the Detail section's Format event to hide/show the controls.
 
Not sure If I can code it to make these visible per entry?
Activate is the wrong event. The most important part of using bound forms/reports is understanding the intended purpose of each event and what causes it to run. Sometimes event order is important also.

Anyway, Activate runs ONCE so it is actually acting on the FIRST record. Look at samples with that in mind and you'll see that if the first record has a condition that will make the control visible - ALL records will have the control visible and if the first record will not show the control, then NO record will show the control.

Arnel is correct. The Detail section's Format event is the one you need to put the code in because it runs before each row is actually printed.. Keep in mind that the Format event might run multiple times so if you are using it to do your own calculations, you need to understand that and not double count any records. The Format event has a FormatCount argument. That tells you what instance this is. It is 1 the first time, 2 the second, etc. It is paired with the Retreat event. For your purposes, the details are not relevant at this time. I just wanted to point this out as reference for others reading the thread.
 
Activate is the wrong event. The most important part of using bound forms/reports is understanding the intended purpose of each event and what causes it to run. Sometimes event order is important also.

Anyway, Activate runs ONCE so it is actually acting on the FIRST record. Look at samples with that in mind and you'll see that if the first record has a condition that will make the control visible - ALL records will have the control visible and if the first record will not show the control, then NO record will show the control.

Arnel is correct. The Detail section's Format event is the one you need to put the code in because it runs before each row is actually printed.. Keep in mind that the Format event might run multiple times so if you are using it to do your own calculations, you need to understand that and not double count any records. The Format event has a FormatCount argument. That tells you what instance this is. It is 1 the first time, 2 the second, etc. It is paired with the Retreat event. For your purposes, the details are not relevant at this time. I just wanted to point this out as reference for others reading the thread.
Thank you
 

Users who are viewing this thread

Back
Top Bottom