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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

referencing in a multipage form 1

Status
Not open for further replies.

Stevo911

Technical User
Apr 26, 2005
33
0
0
ZA
Hi

On a multipage form, lets say with 2 pages. Is it possible to reference a value from a textbox on page 1 when code is executed due to the clicking of a command button on page 2?

So far i have not been able to add arguments to the procedure:

Private Sub cmdInput_Click()

Any help would be greatly appreciated.
Thanks
 
place 2 page multipage in form
place a text box on page 1 of multipage called textbox1
place a text box on page 2 of multipage called textbox2

rightclick the textbox1 and click on view code
the following code should appear by default
Private Sub TextBox1_Change()

End Sub

add the following code to make it complete
Private Sub TextBox1_Change()
TextBox2.Text = TextBox1.Text
End Sub

now every time that TB1 is changed the same value is populated in tb2 on page 2.
Multipages don't have to have to have the page object referenced in the code prior to the object that requires referencing, i.e. you dont do

page2.textbox2.text = page1.textbox1.text


cheers

Matt

crazy times call for crazy people


CrazyPabs

Is it lunchtime yet?
 
Thanks Matt, that helps a lot ...

Is it possible to, for example, reference a textbox on page1, from a command button on page 2 (command button which executes a function which needs values from page 1) without using a textbox on page 2 that is linked to the textbox on page 1?

variablepage2 = page1.textbox1.text (would this work?)

Gonna give it a shot in the meantime ....

Thanks
 
Hi,

use the same principle as explained above, when the user completes the textbox on page 1 but clicks on the button on page 2 you would have something like this...

sub commandbutton1_click()
dim myVariable as string
myVariable = textbox1.text
Sheets(1).select
range("a1").value = myVariable
end sub

this will assign the value of the textbox content to a variable for use in the code. you don't necessaruily need to assign the text value of the textbox to a variable but it helps when reducing the code volumes.


cheers

Matt


crazy times call for crazy people


CrazyPabs

Is it lunchtime yet?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top