close form event is turning off a2k mdb

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

yup,

i am using the following code on a form i designed to let the user specify
their parameters for a report, i.e.

Private Sub CloseForm_Click()
Dim stDocName As String
If CurrentProject.AllReports("Patients on Follow-Up").IsLoaded = True Then
stDocName = "Patients on Follow-Up"
DoCmd.Close acReport, stDocName, acSaveNo
DoCmd.Close acDefault, , acSaveNo
Else: DoCmd.Close acDefault, , acSaveNo
End If
End Sub

the code is behind the click event of a 'CloseForm' button -- i figured i'd
rig this button to test for whether or not the user's actually previewing the
report on his screen. what i want is for the button to close the report AND
then to close the form on which the button resides when the condition's true.
when it's not (as in when the user for some reason decided not to even
preview the form), all i want to happen is for the form to close.

in the second instance it works just fine.

in the first, it closes the report, it closes the switchboard that brought
the user to the form, and it leaves the form on the screen. if you next click
the same 'CloseForm' button a 2nd time, then it closes the form, leaving you
with noting on the screen (but the grey image).

can anybody help me wrap my mind around what's happening?

-ted
 
You aren't specifying what to close. You're leaving it up to Access to close
the item with the focus. Instead of
DoCmd.Close acDefault, , acSaveNo

Try:

DoCmd.Close acForm, Me.Name, acSaveNo
 

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

Back
Top