DoCmd.Close...Closing all my forms!

T

trekgoes2malaysia

Occassionally, when running code in VBA, the "DoCmd.Close" command
ends up closing all the forms I have open in my Access database file
when all I want it to do is close the form or query I last opened with
the DoCmd statement. Why is this happeing and how can I avoid it in
the future?

Example below:

DoCmd.OpenForm stDocName,,,stfilter
getathlete = Me!fname
DoCmd.Close
 
S

Stuart McCall

Occassionally, when running code in VBA, the "DoCmd.Close" command
ends up closing all the forms I have open in my Access database file
when all I want it to do is close the form or query I last opened with
the DoCmd statement. Why is this happeing and how can I avoid it in
the future?

Example below:

DoCmd.OpenForm stDocName,,,stfilter
getathlete = Me!fname
DoCmd.Close

Specify the object you want to close explicitly:

DoCmd.Close acForm, stDocName
 
A

Allen Browne

Specify the form to close, e.g.:
DoCmd.Close acForm, stDocName
or to close the current form:
DoCmd.Close acForm, Me.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