Can I close main form from sub form?

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
 
P

Philo Hamel via AccessMonster.com

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
 
R

Robin Chapple

Philo,

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

Robin Chapple

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
 
V

Van T. Dinh

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.
 

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