How to copy result from one form to anther

romanlo

Member
Local time
Today, 23:55
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.
 
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...
 
They have the same name
 
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
 
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:
 
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

Back
Top Bottom