Solved Label caption to be dynamically generated (1 Viewer)

Bjt

New member
Local time
Today, 10:16
Joined
Jan 11, 2022
Messages
9
Dear all,
I am going around the forum and google since 2 days, but I am not able to solve my problem, so I post it. I am rather newbie to Access, so please have some patience!

I have a form, on which I input some values using a Combo box and text filed, these input values are then used in a query, by making reference to the form:

[Forms]![Extract_Timeliness_data]![txtMonth]
[Forms]![Extract_Timeliness_data]![cmbTeam]

and so on.

After the query I create a report using query's result.

In this report I would have to have dynamic generated label caption, e.g.:

Months: value of [Forms]![Extract_Timeliness_data]![txtMonth]
Team: value of [Forms]![Extract_Timeliness_data]![cmbTeam]

It sounds to me trivial, but apparently it is not.

I did not use SQL but simply the design tools of Access.

Any suggestion is welcome.

Thank you, I.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:16
Joined
May 7, 2009
Messages
19,169
if [Extract_Timeliness_data] form is still Open, then on the Load
event of your report you can set the Labels:

private sub report_load()
Me!Months.Caption = [Forms]![Extract_Timeliness_data]![txtMonth]
Me!Team.Caption = [Forms]![Extract_Timeliness_data]![cmbTeam]
end sub
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 09:16
Joined
Jul 9, 2003
Messages
16,243
I explain the method I use in my blog here:-

 

Bjt

New member
Local time
Today, 10:16
Joined
Jan 11, 2022
Messages
9
if [Extract_Timeliness_data] form is still Open, then on the Load
event of your report you can set the Labels:

private sub report_load()
Me!Months.Caption = [Forms]![Extract_Timeliness_data]![txtMonth]
Me!Team.Caption = [Forms]![Extract_Timeliness_data]![cmbTeam]
end sub
Thank you. But where do I write this code? I am familiar with the use of VBA in Excel, but I do not know where to put the code in Access. Thx
 
Last edited:

Bjt

New member
Local time
Today, 10:16
Joined
Jan 11, 2022
Messages
9
I explain the method I use in my blog here:-
Thank you. I watched the video, but I do not understand how you get the windows with VBA code to be modified. If I click on the button "View Code" I simply sees these 2 lines:

Option Compare Database
Option Explicit
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:16
Joined
May 7, 2009
Messages
19,169
open your Report in design view.
add those 2 labels (if you have not yet done).
follow this steps (with numbered pics)
1. click on the upper-right of the report.
2. on property pane->event->Load (event)
3. choose Code Builder
4. write the code.
s1.png

s2.png

s3.png

s4.png
 

Users who are viewing this thread

Top Bottom