Following skeleton code suggests an approach to your problem. The basic outline is as follows: whenever a textbox gets control it updates a form property LastTextFocus with its reference. This Public Form property is accessible by any other form and will be used to put the focus back.
Program Description:
The first form frmTextBox contains three TextBox controls, appropriately called txtOne, txtTwo an txtThree and a command button cmdDoIt. The latter transfers control to a second form frmDoIt that also contains a command button cmdExit which is supposed to do some usefull work. However, to keep the skeleton as simple as possible, no work is performed. (In your particular case, this button would be replaced by a calendar control).
Whenever a TextBox Gets control, its reference is transferred through the Property Let LastTextFocus to an internal hidden variable m_objLastTextFocus. Which means that the internal variable always will contain a reference to the last active textbox. Of course, all text boxes you want to control must Set this hidden variable. This variable can now be consulted through the Property Get procedure by any external form. This is a standard way to transfer information between forms (cfr: faq222-400 or thread222-37333, thread222-42216, thread222-42637). An ideal place to set the focus back to the right textbox is the Unload event.
Source Listing for frmTextBox
Private m_objLastTextFocus As TextBox
Public Property Get LastTextFocus() As TextBox
Set LastTextFocus = m_objLastTextFocus
End Property
Public Property Let LastTextFocus(objText As TextBox)
Set m_objLastTextFocus = objText
End Property
Private Sub cmdDoIt_Click()
Load frmDoIt
frmDoIt.Show
End Sub
Private Sub txtOne_GotFocus()
LastTextFocus = ActiveControl
End Sub
Private Sub txtTwo_GotFocus()
LastTextFocus = ActiveControl
End Sub
Private Sub txtThree_GotFocus()
LastTextFocus = ActiveControl
End Sub
Private Sub Form_Unload(Cancel As Integer)
Set frmTextBox = Nothing
End Sub
Source Listing for frmDoIt
Private Sub cmdExit_Click()
'Do Your Private Processing
End Sub
Private Sub Form_Unload(Cancel As Integer)
frmTextBox.LastTextFocus.SetFocus
Set frmDoIt = Nothing
End Sub
Note that from within frmDoIt you reference a textbox on another form, therefore you must include its reference frmTextBox
_________________________________
In theory, there is no difference between theory and practice. In practice, there is. [attributed to Yogi Berra]