Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Moving values from one form to another

Posted on 2006-05-01
5
Medium Priority
?
151 Views
Last Modified: 2010-04-07
Hoping somebody can help me out here. I'm working on some forms in Excel. One's a data input form and the other's a calendar.

I've got several controls that take dates as input. In the enter event for each control, I want to be able to open the calendar, pick a date, and return the date to the control that I originally clicked. I can do it manually pretty easy within the calendar:
Form.controlname.value = Calendar1.value
The problem is I have punch in the specific name of the control. Your thoughts?
0
Comment
Question by:jdcollins21
5 Comments
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 16579281

just do it like this:

frmCalendar.show vbModal '<--halts code on this form and turns over execution to modal form.
frmThisForm.controlname.value = frmCalendar.value

Then remove Form.controlname.value = Calendar1.value from the calendar form.

This way all the calendar does is allow the user to select the date, then when the calling form gets back it just grabs that value.


Make sense?

Brian
0
 

Author Comment

by:jdcollins21
ID: 16579613
It's pretty close to what I'm after. Two things.

 Is there a way to get the code to return to the control without specifically naming the control (like active control or storing and referencing the control name)?

Also, using your method, no matter what date I pick on the calendar form, the control value on the input form always jumps back to the original calendar value.
0
 
LVL 19

Expert Comment

by:BrianGEFF719
ID: 16579672
I dont think so jdcollins21.
0
 
LVL 4

Expert Comment

by:yesplease151
ID: 16579737
You would need to move the date using the Calendar.OnClick function.  That way everytime the calendar is clicked, you can pass the new date.  To test this, put this code in, substituting Calendar1 with the name of your calendar control:

Private Sub Calendar1_Click()
MsgBox (Calendar1.Value)
End Sub

That should pop up a box with the correct date everytime you click on the calendar.
0
 
LVL 6

Accepted Solution

by:
junglerover77 earned 2000 total points
ID: 16586704
Of course you can access a control via its name, just like the following:

    UserForm1.Controls("TextBox1").Text = "aaa"

Jungle
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question