Close Form

  • Thread starter mattc66 via AccessMonster.com
  • Start date
M

mattc66 via AccessMonster.com

I have the below code, just before the End If, I have a statement to close
the form. However the form doesn't close. Can anyone see what I am missing?

If cb1 = -1 Then

stDocName = "rptOrderList"
strFilter = "QuoteID = Forms!frmQuotes!quoteID"
DoCmd.OpenReport stDocName, acPreview, , strFilter

DoCmd.SendObject acReport, , acFormatSNP, stEmail _
, , , "Requested Quote for - " & stJob & " Project", "Attached is the
requested quote from " & stBrand & ". Reference Quote#: " & stQuoteNum _
& ". If you cannot view the attachment, you will need to download the
free Snapshot Viewer at www.microsoft.com/downloads", True

DoCmd.Close , "sfrmPrintReport_C2"
End If
 
B

Bill

Matt,

Just for fun, try

DoCmd.Close acform, "sfrmPrintReport_C2"

I believe acform is the default, but perhaps there's
something un-seen that's affecting that.

Bill
 
M

mattc66 via AccessMonster.com

That closed the form, but then I get an odd message:
"The expression you entered refers to an object that is closed or doesn't
exist."
Matt,

Just for fun, try

DoCmd.Close acform, "sfrmPrintReport_C2"

I believe acform is the default, but perhaps there's
something un-seen that's affecting that.

Bill
I have the below code, just before the End If, I have a statement to close
the form. However the form doesn't close. Can anyone see what I am
[quoted text clipped - 14 lines]
DoCmd.Close , "sfrmPrintReport_C2"
End If
 
T

tina

DoCmd.Close , "sfrmPrintReport_C2"

your syntax is incorrect. from Access VBA Help: "Object Name ...If you
leave the Object Type argument blank, leave this argument blank also."
either use both arguments, as

DoCmd.Close acForm, "sfrmPrintReport_C2"

or leave both blank, to close the active window, as

DoCmd.Close

suggest you read up on the Close action in VBA Help, so you'll understand
how it works. an additional note: the name "sfrmPrintReport_C2" makes me
wonder if this is a subform. i mean an actual subform - that is, a form
object embedded inside another form object. (newer programmers tend to use
the term "subform" to refer to a form opened from another form *in a
separate window*; however, a form opened in its' own window is NOT a
subform.) at any rate, you can't "close" a subform directly, you can only
close the parent form the contains the subform.

hth
 

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