Cant Close form after opening another form???

  • Thread starter Thread starter Dave Elliott
  • Start date Start date
D

Dave Elliott

My main form is named BlankChecks and below is the on click code to open the
form BlankChecksNotclr from the main form and should close the main form
BlankChecks
but it does not close the main form, why???

On Error GoTo Err_Command145_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "BlankChecksnotclr"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.Close acForm, Me.Name



Exit_Command145_Click:
Exit Sub

Err_Command145_Click:
MsgBox err.Description
Resume Exit_Command145_Click
 
Try using this for the close command line

DoCmd.Close acForm, "FormName"

don't use ME.
Me refers to the current form in focus which is the one you
just opened.
Jim
 
Because Me.Name is now the last opened, and currently active, form. You
must specify the name of the form to close if you have opened another form.

HTH
Mich
 
Not quite, Mich.

"Me" refers to the Form in whose context the code the code is executed (if
you like, whose Module the code resides in), even if the Form is not the
currently active Form.

I use DoCmd.Close acForm, Me.Name all the time after I open another Form
without any problem. The advantage is that I don't have to change the
statement if I need to change the Form's name.

Me.Name is not the problem in the O.P.'s code but I can't see what's wrong.

HTH
Van T. Dinh
MVP (Access)
 
Back
Top