Can I close main form from sub form?

  • Thread starter Thread starter Robin Chapple
  • Start date Start date
R

Robin Chapple

On this member database when a member is terminated I need to close
the main form because he is no longer a valid member. I will then need
to reopen the form with him missing. ( It is based on a query that
excludes any records with a date in the terminated field.)

I have tried this in the "AfterUpdate" property of the
"DateTerminated" field of the sub form:

DoCmd.Close Me.Parent!

and I get the error message:

""Type declaration character does not match declared data type""

What is the correct technique?

Thanks,

Robin Chapple
 
Might be better to do a Requery on the main form. This way you don't need to
close an reopen the form. Use something like this:

[DB filename].Form_[Main form name].Requery

Later,
Philo
 
Philo,

Thanks for the advice. I am confused by the [DB filename] that is
mentioned. Is the MDB filename?
 
Thanks Van,

DoCmd.Close acForm, Me.Parent.Name, acSaveNo

I have not interpreted you advice correctly.

The main form is "frmMembers". I used this:

DoCmd.Close acForm, Me.Parent.frmMembers, acSaveNo

and I also substituted the name of the sub form. Both gave error 2465.

Robin
 
Sorry, I should have made it clear: Use *exactly* as I posted and don't
change the word "Name".

"Name" is a Property of the Parent Object that return the name of the
Object, in this case, the Form name. This way, the statement still works if
you change the Form's name. In fact, I always use:

DoCmd.Close acForm, Me.Name, acSaveNo

to close my Forms (in the context of the Form).

In you case, the context is the Subform, hence Me.Parent.Name.
 
Back
Top