Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Pass Variable Question

I have a simple form that I load, it asks for a date. It has a submit
button. I want to be able to use that date after the submit button is
clicked. How do I go about doing that in VBA?

Sub Macro()
UserForm.Show
fltDate = UserForm.txtDate.Value
end sub

Private CommandButton_click()

msgbox (fltDate) *** The msgbox is blank ***

end sub

Thanks in advance




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Pass Variable Question

It seems to me that you are already doing what is needed. The things to be
aware of is

- don't unload the form, just hide it, or the variables disappear
- if fltDate is declared as a form variable, make it Public, and qualify the
variable with the form name when using in another module
- if flDate is declared in a standard module, declare it as Public and it
can be used anywhere, without qualification

--

HTH

RP
(remove nothere from the email address if mailing direct)


"SyrHoop" wrote in message
...
I have a simple form that I load, it asks for a date. It has a submit
button. I want to be able to use that date after the submit button is
clicked. How do I go about doing that in VBA?

Sub Macro()
UserForm.Show
fltDate = UserForm.txtDate.Value
end sub

Private CommandButton_click()

msgbox (fltDate) *** The msgbox is blank ***

end sub

Thanks in advance






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Pass Variable Question

Initially hide the userform rather than unload it.

Sub Macro()
UserForm1.Show
fltDate = UserForm1.txtDate.Value
Unload Userform1
end sub

Private CommandButton_click()
msgbox (fltDate) *** The msgbox is blank ***
me.hide
end sub

--
Regards,
Tom Ogilvy


"SyrHoop" wrote in message
...
I have a simple form that I load, it asks for a date. It has a submit
button. I want to be able to use that date after the submit button is
clicked. How do I go about doing that in VBA?

Sub Macro()
UserForm.Show
fltDate = UserForm.txtDate.Value
end sub

Private CommandButton_click()

msgbox (fltDate) *** The msgbox is blank ***

end sub

Thanks in advance






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
pass variable from one workbook to another calebjill Excel Discussion (Misc queries) 2 January 28th 09 07:38 PM
Pass variable to NORMINSV function to get only mean value ExcelMonkey Excel Worksheet Functions 3 June 19th 06 06:01 PM
How to pass a variable into an SQL statement CLamar Excel Discussion (Misc queries) 0 June 5th 06 02:17 PM
How to (re)set a range.value to pass -0- to a "double" variable Dennis Excel Discussion (Misc queries) 2 April 15th 05 11:13 AM
How to pass variable value between macros BCS Excel Programming 0 July 25th 03 08:01 PM


All times are GMT +1. The time now is 06:05 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"