By the way, you could put the code on the close event of the report, then both the report and the form will be closed when completed. -- Advice to Posters. Check your post for replies or request for more information. Consider providing some feed back to the response you have recieved. Kindest Regards Mike B
"MikeJohnB" wrote:
[Quoted Text] > DoCmd.Close acForm, "YourFormNameHere" > > Hope this helps? > > Regards > -- > Advice to Posters. > Check your post for replies or request for more information. > Consider providing some feed back to the response you have recieved. > Kindest Regards Mike B > > > "Emine" wrote: > > > I have a form that allows you to select one or several reports for preview by > > using a command button. I want the Form that has the selection of reports to > > automatically close after I've hit the print button. > > > > Here is my code. What Event Procedure do I use? > > > > Private Sub Report_Open(Cancel As Integer) > > > > Dim Bar As Office.CommandBar > > Dim Ctrl As Office.CommandBarControl > > > > For Each Bar In Application.CommandBars > > If Bar.Name = "Print Preview" Then > > Bar.Visible = True > > For Each Ctrl In Bar.Controls > > If TypeOf Ctrl Is Office.CommandBarButton Then > > If Ctrl.Caption = "&Print" Then > > ' instead of using captions you may use > > ' Ctrl.ID = 2521 > > ' but i don't if its the same ID in all > > ' Access versions. > > Ctrl.OnAction = "DoPrint" > > End If > > End If > > Next Ctrl > > End If > > Next Bar > > > > End Sub > > > > with > > > > Public Sub DoPrint() > > End Sub > > > > > >
|