Sending a parameter to a Userform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
--
 
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
'<<=============
 
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.
 
Dave said:
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.
 
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..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top