Problem with SendObject and modal/popup form

G

Guest

I have a modal popup form which sends a report as email. It opens the report
in acPreview mode, sends it with SendObject and then closes it.

The problem is that after the report has closed, the form no longer acts
modaly enen though its modal property is still true. The user is able to
click on other forms, inckuding the main access application window. This is
dangerous as it allows the user to get at functions which should be
inaccesible.
 
G

Guest

Is there a specific reason to open report in Preview before you send it -
have you tried just sending the report - that should not compromize the
modality of your form.
 
G

Guest

Yes, there is a reason. I need to give the report a where clause and some
information in OpenArgs. I shall investigate other ways of doing that,
possibly by passing the necessary information in global variables. I suppose
I could also let the report's OnOpen handler access the controls on the form
which I use to set up the request for the report.
 
G

Guest

Sergey, I've now tried what you suggested. It made no difference. The form
still does not act modally on return from the SendObject. It must be
something to do with what happens while outlook express is running, getting
recipients addresses, etc.

I forgot to mention previously that after outlook express has run, no window
has focus (at least all title bars are unhighlighted). I had to put a
SetFocus into my code after returning from SendObject. This applies whether
or not I include the open and close for the report.
 
G

Guest

John,

Unfortunately I did not have a chance to work with SendObject in Access -
but if Access behaves the way you describe, we may try to play with the code.
For example, have your modal form expose a public property, and public method:

Public ReadOnly Property Get OkToClose
Public Sub SendReport()

then have this form opened with a code similar to the following:
On Error Goto my_Err
DoCmd.Open acForm, "MyFormName",.., acHidden ' do not remember the exact
syntax
Set myFormVariable = Forms("MyFormName")
Do
' open Form Modally
DoCmd.Open acForm, "MyFormName", ... acModal ' do not remember the exact
syntax
If SysCmd(acSysCmdGetObjectState, acForm, "myFormName") = acObjStateOpen Then
If frmFormVariable.OkToClose Then
DoCmd.Close acForm, "MyFormName"
Exit Do
Else
DoCmd.Echo False
myFormVariable.SendReport
DoCmd.Echo True
' on the next loop iteration the form will be displayed again modally
End If
End If
Loop

my_Exit:
DoCmd.Echo True
my_Err:
MsgBox Err.Description
Resume my_Exit
 

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