DcCmd.Close - code question

  • Thread starter Thread starter Slez via AccessMonster.com
  • Start date Start date
S

Slez via AccessMonster.com

I have a form, "frmImportNewProject", with an unbound control named
"NewProject" where I enter the value of a field "JobNumber", then click a
command button "cmdImportProject", which runs SQL in the On Click event that
appends a recordset to some tables. After I click the command button, and
the process runs, I'd like the form to close.

I tried to add the code - DoCmd.Close acForm, frmImortNewProject - to
the end of the event, but I got an error message. What am I missing in that
code?

Thanks in advance!
 
I'd actually use:
DoCmd.Close acForm, Me.Form.Name

Just in case you or someone else changes the name of the form down the
road.
 
e.mel said:
I'd actually use:
DoCmd.Close acForm, Me.Form.Name

Good point; though I can't think of any reason to insert the .Form
qualifier, since the code is running in the Form object. On the other
hand -- just to add my own two cents -- I usually also specific
acSaveNo, so as to ensure that no user-made design changes get saved:

DoCmd.Close acForm, Me.Name, acSaveNo
 
Back
Top