Good morning:
Thanks for the reply. I load the sourceobject when I click the 'Edit' button. The 'Edit' button is on the mainform and the vba code associated with it is on the mainform.
The 'Close' button is on the subform and the vba code associated with it is on the subform. I need to close the subform when the 'Close' button is pressed and stay on the mainform.
Here is some of the code:
Mainform Code - (Record Source - Original_Control)
================================================== ===========
'This opens the subform when the Edit button is clicked and the Edit button is disabled.
Private Sub cmdEdit_Click()
On Error GoTo Err_cmdEdit_Click
txtMousewheel1.SetFocus
cmdEdit.Top = 1260
cmdEdit.Left = 11279.952
Revision_Control_SubForm.Visible = True
Revision_Control_SubForm.Top = 2040.048
Revision_Control_SubForm.Left = 7139.952
Exit_cmdEdit_Click:
cmdEdit.Enabled = False
Exit Sub
Err_cmdEdit_Click:
MsgBox Err.Description
Resume Exit_cmdEdit_Click
End Sub
================================================== ==========
Subform Code (SourceObject Name - Revision_Control_SubForm)
================================================== =========
'This will let me select an item
Private Sub cboRCName_AfterUpdate()
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[lblRCName] = '" & Me![cboRCName] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
txtMousewheel2.SetFocus
End Sub
------------------------------------------------------
' This will close the subform and mainform. I need it to just close the subform.
Private Sub cmdRCClose_Click()
txtAllowSave = False
txtMousewheel2.SetFocus
On Error GoTo Err_cmdRCClose_Click
'lblRCName.Visible = False
'cboRCName.Visible = False
'lblRCVersion.Visible = False
'txtRCVersion.Visible = False
'lblRCModifications.Visible = False
'txtRCModifications.Visible = False
'lblRCModifier.Visible = False
'cboRCModifier.Visible = False
'lblRCModifiedDate.Visible = False
'dtRCOModifiedDate.Visible = False
'cmdRCSave.Visible = False
'cmdRCUndo.Visible = False
'cmdRCClose.Visible = False
DoCMD.Close
Exit_cmdRCClose_Click:
Exit Sub
Err_cmdRCClose_Click:
MsgBox Err.Description
Resume Exit_cmdRCClose_Click
End Sub
================================================== ================
Edit... I figured it out. I had to set focus away from the subform so
I added.
Me.Parent!txtMousewheel1.SetFocus
Then I added this command under the Private Sub cmdRCClose_Click() routine
Me.Parent!Revision_Control_SubForm.Visible = False.
The following site has a great reference.
http://www.mvps.org/access/forms/frm0031.htm
Thanks,
Tony