View Single Post
  #2  
Old May 28th, 2010, 02:06 AM posted to microsoft.public.access.forms
Lord Kelvan
external usenet poster
 
Posts: 637
Default Add code to CloseButton

oh the pain you are using subforms...

Private Sub btnclose_Click()
If IsNull(Forms![frmMainForm]![frmsubform]!subformcontrol.Value)
Or Forms![frmMainForm]![frmsubform]!subformcontrol.Value = "" Then
MsgBox "Enter product code.", vbOKOnly, "Product code missing"
Forms![frmMainForm]![frmsubform].SetFocus
Forms![frmMainForm]![frmsubform]!subformcontrol.SetFocus
Else
DoCmd.Close
End If
End Sub

also as a note you need to set focus to the subform first before you
can set focus tot he control on the subform


this is your problem Form.Control

Regards
Kelvan