How to close a form from its subform

  • Thread starter Thread starter .Len B
  • Start date Start date
L

.Len B

Form_BeforeUpdate(Cancel As Integer)
If Not chkOk2Save Then
Cancel = True
MsgBox "Ok to save is not checked"
Else
MsgBox "Saving"End If

I have tried several combinations of the >>>> line.
Me.Parent.Close
DoCmd.Close
DoCmd.Close acForm, Forms("frmEnterNotes")
All fail with different errors.

What is the correct way to do this?
Or do I have to close from the parent?
 
Close is looking for a name, not an object.

Try:

DoCmd.Close acForm "frmEnterNotes"

or

DoCmd.Close acForm Me.Parent.Name
 
Intellisense told me it wanted an ObjectName. I saw only Object.
Thanks Douglas. Tried first suggestion. It worked. Stopped there.
--
Len
______________________________________________________
remove nothing for valid email address.
| Close is looking for a name, not an object.
|
| Try:
|
| DoCmd.Close acForm "frmEnterNotes"
|
| or
|
| DoCmd.Close acForm Me.Parent.Name
|
| --
| Doug Steele, Microsoft Access MVP
|
| (no e-mails, please!)
|
|
|
| | > Form_BeforeUpdate(Cancel As Integer)
| > If Not chkOk2Save Then
| > Cancel = True
| > MsgBox "Ok to save is not checked"
| > Else
| > MsgBox "Saving"
| >>>>> DoCmd.Close acForm, Forms!frmEnterNotes
| > End If
| >
| > I have tried several combinations of the >>>> line.
| > Me.Parent.Close
| > DoCmd.Close
| > DoCmd.Close acForm, Forms("frmEnterNotes")
| > All fail with different errors.
| >
| > What is the correct way to do this?
| > Or do I have to close from the parent?
| > --
| > Len
| > ______________________________________________________
| > remove nothing for valid email address.
| >
| >
|
 
Back
Top