How to close a form from its subform

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?
 
D

Douglas J. Steele

Close is looking for a name, not an object.

Try:

DoCmd.Close acForm "frmEnterNotes"

or

DoCmd.Close acForm Me.Parent.Name
 
L

.Len B

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.
| >
| >
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top