Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Copying TextBox entry from one UserForm to another

When UserForm4 comes up, the user enters data in TextBox1. When the
user completes UserForm4, he clicks Next, and UserForm6 comes up. I
would like the number entered in TextBox1 of UserForm4 to automatically
populate TextBox7 of UserForm6.
Can this be done?

Thanks,
J.O.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 58
Default Copying TextBox entry from one UserForm to another

excelnut1954 wrote:
When UserForm4 comes up, the user enters data in TextBox1. When the
user completes UserForm4, he clicks Next, and UserForm6 comes up. I
would like the number entered in TextBox1 of UserForm4 to automatically
populate TextBox7 of UserForm6.
Can this be done?

Thanks,
J.O.



' ------------------------------define this to constant somewhere
public const CancelClicked = 0
public const NextClicked = 1



'----both user form code

Option Explicit

Private m_bResult As Boolean
Property Get Result() As Boolean
Result = m_bResult
End Property

Private Sub btnCancel_Click()
m_bResult = CancelClicked
Hide
End Sub
Private Sub btnNext_click()
If Not ValidateUserInput() Then Exit Sub
m_bResult = NextClicked
Hide
End Sub



Private Function ValidateUserInput() As Boolean
ValidateUserInput = False

'if data don't fit criteria then exit function

ValidateUserInput = True

End Function





' -------------- your module code


load UserForm4
UserForm4.Show

if UserForm4.Result = NextClicked then
load UserForm6
UserForm6.TextBox7.value = userForm4.TextBox1.value
UserForm6.Show
' do something with values from UserForm6
unload userForm6
end if
unload UserForm4



-------------------------
The clue is that data are initiated and processed in parent module not
in user form directly.
Initiated after loading user form , processed after returning from .show

In general user form shouldn't interact with data which is not a part of
user form.
Everything can be done in parent module after hiding user form.


Try to not have unload me in your user form and you'll see that
everything becomes simpler.









  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Copying TextBox entry from one UserForm to another

I sure do appreciate your help. But, I really don't know where to put
all this code. Some of it makes sense, but I just don't know where it
goes. I've tried putting it all into a seperate Module, but it isn't
right. Guess I'm not experienced enough to understand the terminology.
Thanks,
J.O.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Copying TextBox entry from one UserForm to another

I'm sure the code Kris entered above is correct.

But, is there anyone who can simplify it? What I want seems do be just
a simple Copy & Paste situation. I know that's not how this all works,
but there has to be a simplier way to do this.

I just want TextBox7 of UserForm6 to automatically be what was just
entered in TextBox1 of UserForm4.

Can anyone help?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Copying TextBox entry from one UserForm to another

In a general module, put in code like

Public myvar as String

in Userform4 code module put in

Sub TextBox1_Change()
myvar = Textbox1.Value
End sub

In Userform6 code module

Private Sub Userform_Activate()
Textbox7.Value = MyVar
End Sub

--
Regards,
Tom Ogilvy


"excelnut1954" wrote in message
oups.com...
I'm sure the code Kris entered above is correct.

But, is there anyone who can simplify it? What I want seems do be just
a simple Copy & Paste situation. I know that's not how this all works,
but there has to be a simplier way to do this.

I just want TextBox7 of UserForm6 to automatically be what was just
entered in TextBox1 of UserForm4.

Can anyone help?





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Copying TextBox entry from one UserForm to another

Just some more info on what I have already, that may effect what I'm
trying to do now. There is already code in UserForm4 that makes sure
the entry of TextBox1 isn't already on the list. I want to make sure
this isn't conflicting with what I'm trying to do above. Trying to
cover all bases. Is there a problem with having code in both of the
subs shown below for TextBox1? A "change" sub, and an "exit" sub. Here
are the 2 subs.

('This is the code you had me put in, that would help auto enter the
value in UserForm6)
Private Sub TextBox1_Change()
myvar = TextBox1.Value

End Sub

(This is code I had in there already, to make sure of no duplicates
resulting from entry of TextBox1)
Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
'This will check to make sure the user entry is not already on
'the list. If so, message box comes up.

With Worksheets("Official list")
If TextBox1.Text < "" And Not .Range("j:j").Find(TextBox1.Text,
LookIn:=xlValues, lookat:=xlWhole, MatchCase:=False) Is Nothing Then
MsgBox "This PO/PL is already on the list. Please enter the
information in the existing Record."
TextBox1.Text = Clear
Cancel = True

End If
End With

End Sub

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 175
Default Copying TextBox entry from one UserForm to another

OK... I got it. Fooled around, and with some more reading, I found out
about the Declaration part of a Module. WHEW.
I really appreaciate the help!!
J.O.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
TextBox copying not like windows copying, heh? Antoine Excel Programming 3 August 16th 05 03:35 PM
Validate textbox entry Stuart[_21_] Excel Programming 2 May 13th 05 07:31 PM
Ensuring UserForm Textbox Entry is numeric [email protected] Excel Programming 3 October 8th 04 11:20 PM
Validate Textbox entry David Seebaran Excel Programming 3 April 18th 04 06:26 PM
UserForm TextBox to ActiveSheet TextBox over 256 characters Dan E[_2_] Excel Programming 1 July 28th 03 07:36 PM


All times are GMT +1. The time now is 08:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"