Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Sending a parameter to a Userform

Is there a way to pass a parameter to a Userform (similar to openargs in an
access form)?

I have a calendar (Userform) that returns a date. I want the calendar to be
initialized with the parameter date or with today's date if the parameter
value is empty.

Dave
--
newbie AND < expert

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Sending a parameter to a Userform

Hi Dave,

One way:

In a standard module, before any procedures, insert:

Public myDate As Date


Again in a standard module:
'=============
Public Sub Tester()
myDate = CDate("21/10/05")
UserForm1.Show
End Sub
'<<=============

In the Userform module:
'=============
Private Sub UserForm_Initialize()
Me.Calendar1.Value = myDate
Me.CommandButton1.Default = True
End Sub
'<<=============


---
Regards,
Norman


"Dave Scott" wrote in message
...
Is there a way to pass a parameter to a Userform (similar to openargs in
an
access form)?

I have a calendar (Userform) that returns a date. I want the calendar to
be
initialized with the parameter date or with today's date if the parameter
value is empty.

Dave
--
newbie AND < expert



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Sending a parameter to a Userform

Hi Dave,

In the interests of explicitness,

myDate = CDate("21/10/05")


sets the date value which is then used in the UserForm_Initialize event to
determine the initial calendar date.


---
Regards,
Norman



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Sending a parameter to a Userform

Dave Scott wrote:
Is there a way to pass a parameter to a Userform (similar to openargs in an
access form)?

I have a calendar (Userform) that returns a date. I want the calendar to be
initialized with the parameter date or with today's date if the parameter
value is empty.

Dave



userform1 code
-------------
public myInput as variant
public myOutput as variant


main module
-------------

load userform1

userform1.myInput = "something"
userform1.show

a = userorm1.myOutput
unload userform





at the end of userform, when user clicks ok, you should hide userform
(don't unload it).

you can replace variables by properties defined by you.


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Sending a parameter to a Userform

Hi witek and Norman,
Thanks for your help. A combination of your ideas did in fact work.
Declaring my input variable as a variant was what was required to handle
someone closing the form by clicking a Cancel button or pressing the Escape
key and for doing so with no date actually selected..

newbie AND < expert



"witek" wrote:

Dave Scott wrote:
Is there a way to pass a parameter to a Userform (similar to openargs in an
access form)?

I have a calendar (Userform) that returns a date. I want the calendar to be
initialized with the parameter date or with today's date if the parameter
value is empty.

Dave



userform1 code
-------------
public myInput as variant
public myOutput as variant


main module
-------------

load userform1

userform1.myInput = "something"
userform1.show

a = userorm1.myOutput
unload userform





at the end of userform, when user clicks ok, you should hide userform
(don't unload it).

you can replace variables by properties defined by you.



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
How to choose if I use a parameter or not in a parameter query Arnaud Excel Discussion (Misc queries) 0 March 8th 07 01:19 PM
Format when sending a range as parameter to a custom function George Furnell Excel Programming 2 December 1st 05 05:22 PM
Looping procedure calls userform; how to exit loop (via userform button)? KR Excel Programming 6 July 27th 05 12:57 PM
Sending Userform data to different sheets Richard Excel Programming 0 June 8th 05 10:49 AM
Activating userform and filling it with data form row where userform is activate Marthijn Beusekom via OfficeKB.com[_2_] Excel Programming 3 May 6th 05 05:44 PM


All times are GMT +1. The time now is 04:17 PM.

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"