Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

multiple forms 1

Status
Not open for further replies.

RonMex

Programmer
May 1, 2011
2
US
i have a macro with multiple forms. how to i read information from one form to another. for example if form1 has checkboxes and radio buttons how do i read if whether or not the check box was selected and the radio button was selected in form3.
 
The solution depends on application requirements (immediate reaction vs. storage of data, dynamic vs. static datasets). You can use for instance:
1. global variables defined in standard module, set by control's events,
2. broadcasting class that gets data and rises events, WithEvents declaration in form's module that has to pick data.



combo
 
If I am reading your question correctly and you are referring to Access forms, you have to reference controls on other forms by using something like 'forms!form1.checkboxname' in the code in form3.

Or maybe I am not reading the question properly...
 
In the simplest case, where:

you have two forms and

you want to allow the user to make changes to form 1 and then

you want the user to perform an operation on form 2 which requires that form 2 knows the state of form 1.

...what you could do is add a property to form 1 which reports the relevant data when it is interrogated.

Here is a simple example. Create two userforms. On userform 1 add a textbox. On userform 2, add a commandbutton and a label.

Include the following code:

On userform1:
Code:
Public Property Get TextValue() As Variant
TextValue = TextBox1.Text
End Property

On userform2:
Code:
Private Sub CommandButton1_Click()
Label1 = UserForm1.TextValue
End Sub

in the code for the worksheet 1:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
UserForm1.Show False
UserForm2.Show False
End Sub

Does that do what you need?

Tony





 
Sorry, if it isn't already obvious, i should have pointed out that the code in the workbook is simply a quick 'n' dirty way of running the forms to enable you to see how they work. You could equally well have created a module and added the code:
Code:
Public Sub showforms()
userform1.Show False
userform2.Show False
End Sub

Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top