M
Mark
Is it possible to pass a control name to a function on another form,
that function then changes the value of the control specified.
that function then changes the value of the control specified.
Pass the name of the calling form, and the name of the control as the
OpenArgs in your OpenForm call:
DoCmd.OpenForm "CalendarForm", OpenArgs:="Form=MyForm;Control=MyTextBox"
(replace MyForm and MyTextBox with the correct values)
In the calendar form, check whether OpenArgs is Null or not. If it isn't,
parse the value of OpenArgs to determine the name of the calling form, and
the name of the calling control. Once you know them, populate that field.
Here's a snippet that shows how I do it:
Dim lngLoop As Long
Dim strControl As String
Dim strForm As String
Dim varCurrArg As Variant
Dim varArgs As Variant
If Len(Trim$(Me.OpenArgs & vbNullString)) > 0 Then
varArgs = Split(Me.OpenArgs, ";")
For lngLoop = LBound(varArgs) To UBound(varArgs)
varCurrArg = Split(varArgs(lngLoop), "=")
If UBound(varCurrArg) > 0 Then
Select Case varCurrArg(0)
Case "Form"
strForm = varCurrArg(1)
Case "Control"
strControl = varCurrArg(1)
Case Else
End Select
End If
Next lngLoop
If Len(strForm) > 0 And Len(strControl) > 0 Then
Forms(strForm).Controls(strControl) = MyValue
End If
End If
(where MyValue is whatever you're trying to pass back to the calling form.)