Jack and Pat
drawbridgej at sympatico.ca
Wed Sep 30 19:17:17 CDT 2009
Hey Max, You got something for this : Call mcmModuleLogging("MCM_Calendar", "PopCal", True) And This gbMcmModuleLogging? Jack/Freddy -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Max Wanadoo Sent: Wednesday, September 30, 2009 7:48 PM To: 'Access Developers discussion and problem solving' Subject: Re: [AccessD] How do I pass a controlto a function in the ControlSource Hi Jurgen, This is what =Popcal(true/False) will call. Hope it makes sense. Max Function PopCal(bAllowEdit As Boolean) As Variant 'Boolean ' calls the calendar with a flag to indicate if dates can be edited If gbMcmModuleLogging = True Then Call mcmModuleLogging("MCM_Calendar", "PopCal", True) Dim ctl As Control, varCurValue As Variant On Error GoTo errhandler Set ctl = Screen.ActiveControl ' this will determine which date control was clicked on varCurValue = ctl.Value ' Uncomment one of the other of the u/m, depending on whether you want to allow null ' dates or default to today's date ' Screen.ActiveControl = Nz(modDoCalendar(varCurValue, bAllowEdit), Nz(varCurValue, Date)) PopCal = Nz(modDoCalendar(varCurValue, bAllowEdit), varCurValue) Screen.ActiveControl = PopCal exithere: If gbMcmModuleLogging = True Then Call mcmModuleLogging("MCM_Calendar", "PopCal", False) Exit Function errhandler: MsgBox "Error in MCM_Calendar.PopCal: " & Err.Number & vbCrLf & Err.Description Resume exithere End Function Private Function modDoCalendar(Optional varpasseddate As Variant, Optional bAllowChanges As Boolean) As Variant ' if bAllowChanges is not passed in then the default is False (ie, user cannot change date) If gbMcmModuleLogging = True Then Call mcmModuleLogging("MCM_Calendar", "modDoCalendar", True) Dim varStartDate As Variant, strOpenArgs As String On Error GoTo errhandler ' If they passed a date value at all, attempt to use it as the start date. varStartDate = IIf(IsMissing(varpasseddate), Date, varpasseddate) ' OK, so they passed a value that wasn't a date. ' Just use today's date in that case, too. If Not IsDate(varStartDate) Then varStartDate = Date strOpenArgs = varStartDate & "=" & IIf(bAllowChanges, "Yes", "No") DoCmd.OpenForm FormName:=conCalendarFormName, WindowMode:=acDialog, OpenArgs:=strOpenArgs ' If the form is still loaded, then get the final chosen date from the form. ' If it isn't, return Null. If (SysCmd(acSysCmdGetObjectState, acForm, (conCalendarFormName)) <> 0) Then modDoCalendar = Forms![MCM_Calendar]![MCM_CalendarSub]!TextValue DoCmd.Close acForm, conCalendarFormName Else modDoCalendar = Null End If exithere: If gbMcmModuleLogging = True Then Call mcmModuleLogging("MCM_Calendar", "modDoCalendar", False) Exit Function errhandler: MsgBox "Error in MCM_Calendar.modDoCalendar: " & Err.Number & vbCrLf & Err.Description Resume exithere End Function -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com