Dan Waters
dwaters at usinternet.com
Thu Aug 28 11:13:44 CDT 2003
Steve, When the PopupCalendar function has the ctlForm = Forms!frmCalendar!txtStartDate, what is next? Of course I get an error when I add this line of code, but what to actually do I don't know. Call ctlForm_AfterUpdate Thanks, Dan -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Steve Capistrant Sent: Thursday, August 28, 2003 9:33 AM To: Access Developers discussion and problem solving Subject: RE: [AccessD] Calling an AfterUpdate Event in a different form. Oops, I spoke too soon. You were already handling it in a public area. The thing you are missing is this: send the control as one of the parameters in the function. for example, your function name should look like: Public Function PopupCalendar(ctlForm as control, txt As TextBox) As Variant What you pass for the control parameter is the fully qualifed form and control name, like forms!frmCalendar!txtStartDate Then your function already has everything it needs, and you don't have to run through a burdensome Select Case process to guess which context is being used. Steve Capistrant Symphony Information Services scapistrant at symphonyinfo.com Phone: 612-333-1311 www.symphonyinfo.com 212 3rd Ave N, Ste 404 Minneapolis, MN 55401 -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com]On Behalf Of Dan Waters Sent: Thursday, August 28, 2003 10:18 AM To: Database Advisors Subject: [AccessD] Calling an AfterUpdate Event in a different form. Is this possible? I have a calendar form that is triggered by double-clicking in a date field. Putting the date into the correct field works fine, but I need to be able to trigger the AfterUpdate event for whatever date field is on whatever form, and I haven't been able to figure this out. The AfterUpdate event is Public. The associated code is below, and is in a standard module: Public Function PopupCalendar(txt As TextBox) As Variant On Error GoTo EH [IN THIS EXAMPLE, txt = txtDateStart FROM THE CALLING FORM] Dim frmCal As Form Dim varStartDate As Variant Dim frmParent As Form Dim stgParent As String Dim stgAfterUpdateEvent As String If IsNull(txt.Value) Then varStartDate = CurrentDate Else varStartDate = txt.Value End If DoCmd.OpenForm "frmCalendar", , , , , acDialog, varStartDate If IsFormLoaded("frmCalendar") = True Then Set frmCal = Forms("frmCalendar") txt.Value = Format(DateSerial(frmCal!Year, frmCal!Month, frmCal!Day), "m/d/yy") stgParent = txt.Parent.Name Set frmParent = Forms(stgParent) stgAfterUpdateEvent = txt.Name & "_AfterUpdate" Call frmParent.stgAfterUpdateEvent [THIS IS WHAT I WANT - BUT NO DICE!] Call frmParent.txtDateStart_AfterUpdate [THIS WORKS, BUT WOULD NEED A CASE FOR EVERY FIELD!] DoCmd.Close acForm, "frmCalendar" Set frmCal = Nothing End If Exit Function EH: Application.Echo True Call GlobalErrors("", Err.Number, Err.Description, CurrentObjectName, "PopupCalendar", txt) End Function _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com _______________________________________________ AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com