Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Calendar on one Form from a Command Button on another Form 1

Status
Not open for further replies.

netrusher

Technical User
Feb 13, 2005
952
US
I have a date field on a Subform (ECNDetail) Mainform (ECNBCNVIPtbl). When the date field is clicked I want
to open another form that has instructions (EcnPopup1)(no problem with that). I have a Command Button
(CloseForm) that I would like to serve two purposes if possible. I would like for it to close the form and open
up a Calendar (CalMain1) on my Subform (ECNDetail). Is this possible and if so How. Below is the code that
I currently have. I appreciate all help with this. What our purpose is, before a date is put in the [Pending Date]
Field I want the (EcnPopupp1) to come up with work instructions. Then when the Ok or Close Form is clicked I
want the Calendar to popup so a date can be selected. I am open to try another way if someone has other
suggestions. Thanks for all help.

Please see code below. I have rem'd out the Close form part of the code. I know I somehow much call out
the form where the Calendar is located but I have not been able to accomplish this.

Code:
Private Sub CloseForm_Click()
   CalMain1.Visible = True
   CalMain1.SetFocus
   If Not IsNull([Pending Date]) Then
      CalMain1.Value = [Pending Date].Value
   Else
      CalMain1.Value = Date
      
   End If
'On Error GoTo Err_CloseForm_Click

'    DoCmd.Close

'Exit_CloseForm_Click:
'    Exit Sub

'Err_CloseForm_Click:
'    MsgBox err.Description
'    Resume Exit_CloseForm_Click
   
End Sub
 
How are ya netrusher . . .

If you used a Msgbox instead, you could keep focus on the subform and go from there.

For your posted secnario, all you really need is a proper reference to the subform:
Code:
[blue]Private Sub CloseForm_Click()
   Dim [purple][b]sfrm[/b][/purple] As Form
   
   Set [purple][b]sfrm[/b][/purple] = Forms!ECNBCNVIPtbl!ECNDetail.Form
   
   [purple][b]sfrm[/b][/purple]!CalMain1.Visible = True
   [purple][b]sfrm[/b][/purple]!CalMain1.SetFocus
   
   If Not IsNull([purple][b]sfrm[/b][/purple]![Pending Date]) Then
      [purple][b]sfrm[/b][/purple]!CalMain1.Value = [purple][b]sfrm[/b][/purple]![Pending Date].Value
   Else
      [purple][b]sfrm[/b][/purple]!CalMain1.Value = Date
      
   End If
   
   Set [purple][b]sfrm[/b][/purple] = Nothing
  
End Sub[/blue]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top