Link to home
Start Free TrialLog in
Avatar of jdcollins21
jdcollins21

asked on

Moving values from one form to another

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?
Avatar of BrianGEFF719
BrianGEFF719
Flag of United States of America image


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
Avatar of jdcollins21
jdcollins21

ASKER

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.
I dont think so jdcollins21.
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.
ASKER CERTIFIED SOLUTION
Avatar of junglerover77
junglerover77

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial