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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Feed selected Calendar value to text box, depending on box selected 1

Status
Not open for further replies.

THWatson

Technical User
Apr 25, 2000
2,601
CA
Using Access 2000

I have a form, frmAttendance, from which I can call frmCalendar, and feed the Calendar date value selected back to a text box called "txtMeetingDate" on frmAttendance.

The calendar control is called MyCal.

However, I want to be able to open the frmCalendar from another from, frmDateSelector, and feed the value back to it.

I can accomplish the first step by using the following code on the OnClick event for MyCal in frmCalendar...
Code:
If CurrentProject.AllForms("frmAttendance").IsLoaded Then
Forms!frmAttendance!txtMeetingDate = Forms!frmCalendar!MyCal.Value
DoCmd.Close , , acSaveNo

Thus if I open frmCalendar from frmDateSelector no calendar value will be fed back to frmAttendance.

So far so good. However, there are 2 possible text boxes on frmDateSelector from which I want to open frmCalendar by double clicking. One is called txtStartDate, the other is called txtEndDate. I want to feed the date value selected on MyCal to be fed back to whichever text box it is from which I open frmCalendar.

Any suggestions as to the best way to accomplish that?

Thanks.

Tom
 
Can't you use the OpenArgs parameter when you open frmCalendar ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV

Well, maybe...if I can get the code right.

Do you mean something such as
Code:
Private Sub txtStartDate_DblClick(Cancel As Integer)
DoCmd.OpenForm "frmCalendar", , , , , , OpenArgs: Forms!frmDateSelector!txtStartDate = Forms!frmCalendar!MyCal.Value
DoCmd.Close acForm, "frmCalendar", acSaveNo
End Sub

This will give me the date displayed in MyCal upon opening frmCalendar (which will always be today's date), but doesn't allow for changing that value by clicking another date.

As I indicated, the OnClick event for MyCal is already set to feed a value to a txtMeetingDate text box on another form...
Code:
Private Sub MyCal_Click()
   On Error GoTo MyCal_Click_Error

If CurrentProject.AllForms("frmAttendance").IsLoaded Then
Forms!frmAttendance!txtMeetingDate = Forms!frmCalendar!MyCal.Value
DoCmd.Close , , acSaveNo
End If

Tom
 
Calling:
Code:
DoCmd.OpenForm "frmCalendar", , , , , , "frmDateSelector;txtStartDate"
Called:
Code:
a = Split(Me.OpenArgs, ";")
Forms(a(0)).Controls(a(1)) = Me!MyCal.Value

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
PHV

Looks as if that might do it.

In the "called" form, frmCalendar, I had to add
Code:
Dim a as variant

Would that seem to make sense?

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top