How to copy result from one form to anther (1 Viewer)

romanlo

Member
Local time
Today, 14:51
Joined
Feb 24, 2020
Messages
38
Hi there few days ago I had a problem with changing the color of the label. Thanks to cheek.. it is resolved.
II want to:
when I click label on the form1 it changes the color, gives me the correct record after using the printbutton the form2 shows the same selected label with color changed.
I have tried something like:
Code:
Dear Guys. I think I need to learn from very beginning.
I am trying to do the same affect on my second form. I mean. when I press lbl in form1 it changes the color and shows me good record. I wanted this effect to be like a mirror on the second form:
I have tried to use:
Code:Copy to clipboard
 For Each lbl In Me.Controls 'dla każdej zmiennej w zestawie kotrolek tego formualrza
 
    If TypeOf lbl Is Label Then
        lbl.OnClick = "=LabelClick(" & Mid(lbl.Name, Len(LABEL_PREFIX) + 1) & ")"
        DoCmd.OpenForm "Drukuj", acDesign, , , , acHidden
        lbl.OnClick = "=LabelClick(" & Mid(lbl.Name, Len(Forms!Drukuj.Control("Etykieta")) + 1) & ")"
            
  End If
    
  Next
But it is not giving me anything.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:51
Joined
Oct 29, 2018
Messages
21,454
Hi. Do the labels have the same name? If so, then you could capture the name of the selected label and then use it on the other form. Just a thought...
 

romanlo

Member
Local time
Today, 14:51
Joined
Feb 24, 2020
Messages
38
They have the same name
 

romanlo

Member
Local time
Today, 14:51
Joined
Feb 24, 2020
Messages
38
I have tried to capture by:
form2 code
Code:
Private Sub Form_Load()
Dim lab As Control
lab = Me.TabControl.Pages(0).Controls("Etykieta").Caption
lab = Forms!Sektor.LABEL_PREFIX.Caption
'"LABEL_PREFIX" is declared as  Private Const LABEL_PREFIX As String = "Etykieta" in form1
End Sub
But maybe my reference is wrong
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:51
Joined
Oct 29, 2018
Messages
21,454
I have tried to capture by:
form2 code
Code:
Private Sub Form_Load()
Dim lab As Control
lab = Me.TabControl.Pages(0).Controls("Etykieta").Caption
lab = Forms!Sektor.LABEL_PREFIX.Caption
'"LABEL_PREFIX" is declared as  Private Const LABEL_PREFIX As String = "Etykieta" in form1
End Sub
But maybe my reference is wrong
Hi. Maybe I am not understanding what you're trying to do. I thought you said you had some code in Form1, and you want to extend it to also affect Form2. So, is that Load event code from Form1 or Form2? You might want to post a link to your other thread, in case it could provide more context to your current question.
 
Last edited:

romanlo

Member
Local time
Today, 14:51
Joined
Feb 24, 2020
Messages
38
 

Cronk

Registered User.
Local time
Today, 22:51
Joined
Jul 4, 2013
Messages
2,771
If lab is a control variable, then this line will not compile.

lab = Me.TabControl.Pages(0).Controls("Etykieta").Caption
 

Users who are viewing this thread

Top Bottom