Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calendar data across 2 Forms? 1

Status
Not open for further replies.

RiazKhanmohamed

Programmer
Oct 30, 2002
115
I have a form with a textfield that, when I double click on it, opens up another form with a calendar on it. When i double click that, I want the date to be returned to the original textfield. Having searched around on this site, I have set a global variable in the original form:

ctl As Control

On double clicking my textfield, i do this:
**************8
Private Sub FName_DblClick(Cancel As Integer)
Me.Refresh
Set ctl = Forms![RequestHoliday Detail Subform]![FName Date]

Dim stDocName As String
stDocName = "frm_date" 'name of form containing Active X calendar
DoCmd.OpenForm stDocName

End Sub
**********
frm_date is my calendar form, RequestHoliday is my original form. FName is the field (i am just practicing before confirming the names.)

on my calendar form, i have this code:
**********8
Private Sub CalendarBox_DblClick()
Dim d As String, e As Date

'On DblClick, the active datefield on specified form is changed to calendar date
ctl = Me!CalendarBox.Value
'Close
End Sub

***************8
CalendarBox is my calendar ActiveX process.

Please help - it doesn't like ctl, and i just want the date to appear in the other field. The date types are the same, and i'm not sure if the second form is a sub form or just another form, hence not taking in the ctl variable.

Is there a simple solution?
 
All you need on the first form is:

Private Sub FName_DblClick(Cancel As Integer)

Dim stDocName As String
stDocName = "frm_date" 'name of form containing Active X calendar
DoCmd.OpenForm stDocName

End Sub

All you need on the calendar form is:

Private Sub CalendarBox_DblClick()
Dim d As String, e As Date

'On DblClick, the active datefield on specified form is changed to calendar date
Forms![RequestHoliday Detail Subform]![FName Date]= Me!CalendarBox.Value
'Close
End Sub



Please remember to give helpful posts the stars they deserve!
This makes the post more visible to others in need! [thumbsup2]

Robert L. Johnson III, A+, Network+, MCP
Access Developer/Programmer
robert.l.johnson.iii@citigroup.com
 
Thanks - I realised how stupid I was when i took a fresh look at after a few hours away, and as a starting VBA programmer i'm just getting to grips. Thanks again for your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top