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

pop up Calendar and subform 1

Status
Not open for further replies.

logopolis

Technical User
Oct 10, 2002
59
0
0
ES
I have been looking at the set up of a pop up calendar in a form as documented in but I want the field to be in a subform and the pop up calendar to be in the parent form. Is this possible.

John
 
see my thread reply at
thread702-770280

But change it when it puts the data in there to set focus to your subform first.

SubForm.SubFormNameHere.FieldOnSubForm = Format(Me.Calendar,"mm/dd/yyyy")

 
adamroof - I am having the same issue as logopolis. Should I change every reference to "me.calendar" to your code recommendation [SubForm.SubFormNameHere.FieldOnSubForm = Format(Me.Calendar,"mm/dd/yyyy")]?

Even after making your changes, I still get an error that says "You can't hide a control that has the focus".

My code is below.

Private Sub cmdLastUpdateCal_Click()
'adamroof version
If IsNull(Me.txtLastUpdated) Then
SubForm.subfrmStaticData.LastUpdatedCal = Format(Me.LastUpdatedCal, "mm/dd/yyyy")
Me.LastUpdatedCal.Visible = True
Else
Me.LastUpdatedCal = Me.txtLastUpdated
Me.LastUpdatedCal.Visible = True
End If
End Sub

Private Sub LastUpdatedCal_AfterUpdate()
'adamroof version
Me.LastUpdatedCal = Format(Me.LastUpdatedCal, "mm/dd/yyyy")
Me.LastUpdatedCal.SetFocus
Me.LastUpdatedCal.Visible = False
'this is where I get the run-time error ('2165')
End Sub


Any thoughts?
 
Me.Calendar is pointing to the Calendar name you have given it. So if you named it MyCalendar or LastUpdateCal, you will say me.LastUpdateCal, it should auto fill in for you after you type the "me."

The AfterUpdate event needs to set the value in the Text Box that you want the date in. This is what it should be...

Private Sub LastUpdatedCal_AfterUpdate()
Me.txtLastUpdated = Format(Me.LastUpdatedCal, "mm/dd/yyyy")
Me.txtLastUpdated.SetFocus
Me.LastUpdatedCal.Visible = False
End Sub

You get the error because you were setting focus to the Calendar, not the text box.
I think i liquored up my original thread, sorry!
 
Wonderful. That is exactly what I needed. Thanks much for the insight. You get a well-earned star!
 
adamroof -
Not to overly demanding - may be too late - but I have one more issue. I am trying to use either (1) two calendars to fill two date fields or (2) one calendar to fill two date fields.

No matter which way I code it, I keep getting an error stating that an object is required. It is fouling up on:

Private Sub cmdLastReportCal_Click()
If IsNull(Me.txtLastReport) Then
SubForm.subfrmStaticData.LastUpdatedCal = Format(Me.LastUpdatedCal, "mm/dd/yyyy")
Me.LastUpdatedCal.Visible = True
Else
Me.LastUpdatedCal = Me.txtLastReport
Me.LastUpdatedCal.Visible = True
End If
End Sub


The code is exactly the same as the first calendar control, so I am unsure why it is failing.
 
Disregard last message. I actually fixed something for myself :)
 
Check out my post at thread702-770381 for using one calendar to update multiple fields.

Dim strControl As Control globally (forget what you call that per form code)
 
adamroof -
Followed this thread and was successful in implementing a calendar - thanks!

But, as you suggested in your thread, "Sometimes...you cant click on today". I have tried your fixes, but still can't get it to work. Since I am using the calendar in a data entry form (new records only), the selection of today's date will, no doubt, be popular.

Any insight would be appreciated.
 
the onClick event should handle that, but to make things easier for users, dont even use the calendar for entering today! What i have done is create a button next to each field and set the label to "T" (so i can make it a small button)

On Click of button do this...
************
Private Sub tardateTD_Click()
Me!TargetDate.Value = Format(Now(), "mm/dd/yyyy")
End Sub
************
 
also, i figured out how to make the Calendar move to where you want when you click...
The settings are not in the numbering scheme i thought...

move your calendar where it should pop up, then adjust the position by setting a break point in code just before it moves the calendar, hover over the value when it debugs the code and it will tell you in pixels, not inches (it wants pixels in code) adjust as needed inputting the values in code where it needs to go.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top