[AccessD] How do I pass a controlto a function in the ControlSource

Max Wanadoo max.wanadoo at gmail.com
Wed Sep 30 19:26:22 CDT 2009


Hi Jack, just comment it out.

What that does is activate a routine base on a global variable which states
whether or not I want to record the fact that this/that function was called
and later on when it was left.  If global tracking was turned on, then I can
see which functions get *hit* the most and therefore, which I need to
concentrate on to try to improve on performance.  From your point of view,
with regard to =Popcal(), just comment it out.

If you want the actual calendar (as I say, based on Getz et al) then most
happy to send it offline as an mdb.  This has served me well for over a
decade and I *never* have to even look at it.  I am sure it can be improved
on, but for me it works.  You know what they say, If it ain't broke, don't
fix it. LOL.

Max


-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Jack and Pat
Sent: 01 October 2009 01:17
To: 'Access Developers discussion and problem solving'
Subject: Re: [AccessD] How do I pass a controlto a function in the
ControlSource

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

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list