Bandito1

Board Regular
Joined
Oct 18, 2018
Messages
233
Office Version
  1. 2016
Platform
  1. Windows
Hello all,

I got 2 userforms; Productionreturns and QA returns.

Both contain the same labels; lblGelcodeR and lblProductnameR.
Both contain the label info; if you click on it a new form opens: Information

The form Information contains the label lblGelCodeR and lblProductnameR. They should display the same data as on the forms Productionreturns and QA returns.

I use common variables for it;

On the form productionreturn;
Code:
Private Sub lblInfo_Click()
commonVariable = Productionreturns.lblGelCodeR.Caption
commonVariable1 = Productionreturns.lblProductNameR.Caption
GelBMRProperties.Show
End Sub

on the form QAreturn;
Code:
Private Sub lblInfo_Click()
commonVariable2 = QAreturns.lblGelCodeR.Caption
commonVariable3 = QAreturns.lblProductNameR.Caption
GelBMRProperties.Show
End Sub


And when the form information opens;
Code:
Private Sub UserForm_Initialize()
lblGelCodeR.Caption = Productionreturns.commonVariable
lblProductNameR.Caption = Productionreturns.commonVariable1
lblGelCodeR.Caption = QAreturns.commonVariable2
lblProductNameR.Caption = QAreturns.commonVariable3

but this doesn't work. It works seperatly but not together. Seems logic since it gets the labels get info from 2 commonvariable if i read the code correctly. How can i change the code from the form Information that it looks if i click from QAreturn or Productionreturn and then use the right commonvariable?
 
Last edited:

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Re: Using commonvariables

Rather than using variables, just assign the values directly from the lblInfo_Click event like
Code:
Private Sub lblInfo_Click()
   With GelBMRProperties
      .lblGelCodeR.Caption = QAreturns.lblGelCodeR.Caption
      .lblProductNameR = QAreturns.lblProductNameR.Caption
      .Show
   End With
End Sub
 
Upvote 0
Re: Using commonvariables

Thanks for the insight, it works.

Thanks once again :)
 
Upvote 0
Re: Using commonvariables

You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,214,788
Messages
6,121,580
Members
449,039
Latest member
Arbind kumar

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top