switching b/w forms

skate

Registered User.
Local time
Today, 03:46
Joined
May 22, 2002
Messages
136
is there a way to execute a function in the code of a form after hitting ok from another form?
In my formA I have a print and print preview button. As I click it I want to have a formB that pops up asking if you want to view/print the complete list or just the current record. I've put a check option on the form for yes/no and created a separate report based on a query that prints only the records set to yes. If the user chooses the current record to print and hits ok in formB, the check in formA should be set to yes and the preview/print button will display accordingly. I'm sorta in a rut what to do and if I'm going about this the best way. Any suggestions? Thanks.
 
I use a public declatation in a module to enter the report name

Under the
Option Compare Database
Option Explicit

put
Public ReportName as String 'this name can be anything

Then when you hit the print button, instead of docmd.openreport "YourReportName"

put

ReportName = "YourReportName"
DoCmd.OpenForm "PopUpFormName"

In the code on the buttons on your popup forms

Docmd.OpenReport ReportName,acViewPreview
DoCmd.Close acForm, "PopUp"

on the print button

Docmd.OpenReport ReportName
DoCmd.Close acForm, "PopUp"

HTH
Dave
 
If you always want formB to check about all or single records, why not simply invoke the printing/previewing from formB, and when printing is complete, close formB and return to formA?

-Curt
 
After re-reading your post I realize that I answered a question you didn't ask.

Again use a public function in a module

Public PrintSource as String

On your Print / PrintPreview buttons just open the popup form

DoCmd.OpenForm "PopUpFormName"

Then on each of the buttons you can specify a record source for the report.

I presume the 2 reports have 2 queries as record sources.

On the buttons

Button1
PrintSource = "Query1Name"
Docmd.OpenReport "YourReportName"

Button2
PrintSource = "Query2Name"
Docmd.OpenReport "YourReportName"

Step 2

In the Report - Open code put

Me.RecordSource = PrintSource
Me.ReportHeading.Caption = "ReportName"

HTH
Dave
This, I hope is if the 2 reports are the same format (Look)
 
do you know if there is a way such that when hitting the print or preview button on FormA that FormB can tell which button was hit? I would prefer to keep formB as just a option1 option2 form and on close it will execute according to the chosen option. Would work well if it wasn't for both print and preview buttons need to know which option is chosen.
 

Users who are viewing this thread

Back
Top Bottom