PDA

View Full Version : Moving Value to a popup



oxicottin
06-08-2017, 05:15 PM
Hello, The picker is a popup form that I use from my form (frm_MachineOutputSubForm) on a On Click Event. My question is lets say I had already used the picker and there was a time in the text box (txtSampleTime) on the form (frm_MachineOutputSubForm) and I wanted to change it and I click on text box to open the popup form (frm_TimePicker). How do I get it to show the time in the text box on that form and have the sliders hour and minutes move to the correct time?

Thanks,

OBP
06-09-2017, 11:25 AM
Is the real form (frm_MachineOutputSubForm) bound to a table that contains the previously chosen time? ie does the field txtSampleTime have a control source?
If it is this will work

If Not IsNull(Forms.frm_MachineOutputSubForm.txtSampleTime) Then
Me.txtTime = Forms.frm_MachineOutputSubForm.txtSampleTime
Else
MsgBox "no time"
Me.txtTime = CDate(DatePart("h", Now()) & ":" & DatePart("n", Now()))
End If
txtTime_AfterUpdate

HiTechCoach
06-11-2017, 12:39 PM
I am not whre I can look at your attachement at this time.

Wrapper Function:

To make the time picker form generic so it can be reused with other controls on the same form or other forms, I would recommend using a wrapper function. You pass a control reference to the funcition. The function then opens your form. When the form closes the function will pass back the selected value.

I do have a working exampe that shows how to use a wrapper function:

Pop ups (http://hitechcoach.com/microsoft-office/access/access-downloads/access-examples/example-forms/pop-ups-calendar-calculator-zoom-box) - Calendar, Calculator, Zoom box (http://hitechcoach.com/microsoft-office/access/access-downloads/access-examples/example-forms/pop-ups-calendar-calculator-zoom-box)

jonh
06-12-2017, 02:41 AM
Similar to OBP's method.

Add a public variable to a standard module.



Public PickerTime As Date


Set the variable in your MachineOutputSF btn click event.



Private Sub txtSampleTime_Click()
If IsDate(txtSampleTime.Text) Then _
PickerTime = CDate(txtSampleTime.Text) Else _
PickerTime = Now


DoCmd.OpenForm "frm_TimePicker", , , , , acDialog
End Sub


Get value in TimePicker Load



Private Sub Form_Load()
Dim t As Date
If IsDate(PickerTime) Then
t = PickerTime
Else
t = Now
End If

Me.txtTime = CDate(DatePart("h", t) & ":" & DatePart("n", t))
txtTime_AfterUpdate

End Sub


That way your TimePicker code won't break if the MachineOutputSF form isn't open and you don't need to write extra code to check.

oxicottin
06-13-2017, 11:33 AM
Thank you john that worked great, sorry I didn't get back sooner I couldn't get to this.... Thanks again!