Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Passing data back from a form

If you want to pass data from Form to Form or Sub, I have been struggling
with this one, however I muddled through. instead of making your variable
only available in the private sub define it in the declarations of the from
as a public, you can use this in any sub on that form and call it to another
from.. let me show you.

public n as long 'in userform 1 declarations

some routine that gives n it's value, such as selecting form a combobox on
the form
------------------------------

public n as long 'in userform 2 declarations

Private Sub UserForm_Activate() 'on the second form for example
n = UserForm1.n
textbox1.value = n
End Sub

the value n is now available to all subs on both forms. It all depends where
and when you need the value n. Here the value is given when the user form is
activated, it could be on the Form_click. I had a problem when i used it in
the form_initialize, the reason is that the initialize only happens once as
i used .show and .hide in my routines.

I'm not sure if this is the best way to do it but it works for me.

I think you'd be better looking into to change events for the textboxes and
giving the value over. at a guess i'd say

sub textbox1_change()
userform.textbox2.value = textbox1.value
end sub

I dare say theese guru's know a better way, wouldn't mind knowing myself
actually.

Chris A



"Neil" wrote in message
...
I have three forms in my project. Each of them have date
fields, I created a usrForm with a calender control on it
which all works fine. But how do I send the output from
the calender click event back to the correct texbox on
the correct form ?



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
Write data back from a form to sheet Steen Excel Discussion (Misc queries) 9 October 22nd 08 01:22 PM
Passing variables between a form and macro David New Users to Excel 1 October 5th 05 04:42 AM
Passing variables between a form and macro David New Users to Excel 4 September 23rd 05 11:57 AM
Passing data back from a form Taras Excel Programming 0 November 24th 03 04:33 PM
Passing data back from a form Tom Ogilvy Excel Programming 0 November 24th 03 04:27 PM


All times are GMT +1. The time now is 08:32 AM.

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

About Us

"It's about Microsoft Excel"