Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

First Launch Maximixed, 2nd launch minimized

Status
Not open for further replies.

mikelev

Technical User
Mar 23, 2004
223
US
I have a popup form that lists all my reports. Each report has 2 command buttons 1 to preview and 1 to direct print the report. When I launch the report the Main form minimizes so I can see the report viewer. Closing the report maximizes the Main form again. Everything works fine the first time I preview. After closing the report and clicking preview again, Access minimizes going to the task bar?


Preview Button Code


Private Sub Command24_Click()
On Error GoTo Err_Command24_Click


Dim stDocName As String

stDocName = "rptCageInv"
DoCmd.Maximize
DoCmd.OpenReport stDocName, acPreview
DoCmd.close acForm, "REPORTCENTRAL"
DoCmd.close acForm, "STRAIGHTEDGE HOME"
DoCmd.Maximize

Exit_Command24_Click:
Exit Sub

Err_Command24_Click:
MsgBox "Please Re-Enter Your Dates", vbOKOnly
Resume Exit_Command24_Click

End Sub



Any idea's???


Cheers,
 
This is what I do. I do not use a popup because I don't want it to always stay on top. You are having to minimize it to get it out of the way to see your report in Preview mode. This is the problem. Try this:

1. Change for to just a regular rectangular form with its AutoCenter property set to Yes, Modal set to No, Popup set to No. Size, open and Save the form to secure its dimensions and location on the screen.
2. Put this code in the On Active event procedure of this form.
Code:
DoCmd.SelectObject A_FORM, "[i][red]yourformname[/red][/i]"
DoCmd.Restore
3. Now you code will work fine for your report Preview and when you close the Preview Window and the focus returns to the reports section form the OnActive event procedure will execute returning the form to its original location on the screen and having the focus. Just remove the red code below as it is not needed. I don't know what the .close commands are for. What forms are these?

Code:
Dim stDocName As String
stDocName = "rptCageInv"
DoCmd.Maximize
DoCmd.OpenReport stDocName, acPreview
DoCmd.close acForm, "REPORTCENTRAL"
DoCmd.close acForm, "STRAIGHTEDGE HOME"
[red]DoCmd.Maximize[/red]

Good luck. Post back if you have questions.

Bob Scriver
[blue]Want the best answers? See FAQ181-2886[/blue]


 
This what I did to solve it:

On every report:


Private Sub Report_Close()
DoCmd.OpenForm "REPORTCENTRAL", acNormal
End Sub
Private Sub Report_NoData(Cancel As Integer)
MsgBox "No Data To Print", vbOKOnly, "StraightEdge Software"
DoCmd.CancelEvent
End Sub

Private Sub Report_Open(Cancel As Integer)
DoCmd.RunMacro "mcrRestore"
End Sub
Private Sub Report_Activate()
DoCmd.Maximize
End Sub


Code for button:

rivate Sub Command24_Click()
On Error GoTo Err_Command24_Click

Dim stDocName As String

stDocName = "RC_CageInv"
DoCmd.OpenReport stDocName, acPreview
DoCmd.close acForm, "REPORTCENTRAL"
DoCmd.close acForm, "STRAIGHTEDGE HOME"

Exit_Command24_Click:
Exit Sub

Err_Command24_Click:
MsgBox "Please Re-Enter Your Dates", vbOKOnly, "StraightEdge Software"
Resume Exit_Command24_Click

End Sub


Cheers,


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top