Group:  Microsoft Access ยป microsoft.public.access.formscoding
Thread: Close Preview Select Form

Geek News

Close Preview Select Form
Emine 12/10/2008 5:11:00 PM
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



RE: Close Preview Select Form
MikeJohnB 12/10/2008 6:38:14 PM
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:

[Quoted Text]
> 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
>
>
>
RE: Close Preview Select Form
MikeJohnB 12/11/2008 7:50:09 AM
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
> >
> >
> >
RE: Close Preview Select Form
Emine 12/17/2008 6:11:01 PM
THANK YOU SO MUCH JOHN!
--
Thank you all for your support and guidance. What would we all do if it
weren''t people like you out there to help us? Thank you!


"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
> >
> >
> >

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net