Print Query by Form

esskaykay

Registered User.
Local time
Today, 20:36
Joined
Mar 8, 2003
Messages
267
Sorry for reposting this, but I was hoping I (or should I say you) could help resolve my issue.

My original post was:
"I have a Query By Form setup (based on Ken Getz QBF.exe routine) -- it works great. I have one more wish. Is it possible to print the result of the QBF to a specified report?"

I have this working somewhat. I have a PRINT (preview) button that captures the QBF data. However, the PRINT button is on the same screen/form as the VIEW button. I would like is to have the PRINT button appear only on the VIEW screen. That way, once someone has processed a query, if they decied to print it, they don't have to go back to the QBF screen.

I have attached a small sample of my DB. Any suggestions would be greatly appreciated.

Thanks,
SKK
 

Attachments

Here is your Sample Database back to you with the required modifications. I have also made some minor modifications to the frmIndex Form. The Edit Record button no longer hides but instead toggles to a Done button and then Back to Edit Record. When the Caption of the Button reads Edit Record, the Record is locked. When the button Caption reads Done then the record is obviously being worked on (edited) and therefore is unlocked until the Done button is selected in which case the Record is then Locked again.

I also added a Print Button into the frmIndex Form which pops in and out of view depending upon whether or not the Record is being edited. Currently the Print button is capturing the same Data as it was when in the Search Form. I did not remove the Print Button from the Search Form. You can do this yourself if you like....or perhaps use it for some other purpose.

The initial visibility of the Print button within the frmIndex Form is based upon what is passed to the Form within the OpenArgs property of that Form. I conveniently used the word Print to pass along into the OpenArgs property of the frmIndex Form when it is Opened.

.
 

Attachments

CyberLynx,

Without beeing too much of a bother, this is close but when I click PRINT on the frmIndex form I see all the records not just the ones I queried (as show up on when the PRINT button is clicked on the frmSearch form).

I like the Edit/Done option.

Maybe I'm missing something,
SKK
 
(ahem) ...Yes, indeed. That would be helpful wouldn't it. :o

Simple little fix. Should only take a few seconds....

- Open the frmIndex Form in design view;
- Select the Print button control;
- In the Properties Window select the Events tab;
- Remove the =QBFDoHide2([Form]) function call from the OnClick Event;
- Place [Events Procedure] into the OnClick Event property;
- Select the Code Window button [--] located at the end of the Property line;
- Copy and Paste this wee bit of code into the PrintBut procedure;

Code:
If Len(Me.Filter) > 0 And Me.RecordsetClone.RecordCount > 0 Then
   DoCmd.OpenReport "R_Index", acViewPreview, , Me.Filter
End If

the entire procedure should look like this:

Code:
Private Sub PrintBut_Click()
   If Len(Me.Filter) > 0 And Me.RecordsetClone.RecordCount > 0 Then
      DoCmd.OpenReport "R_Index", acViewPreview, , Me.Filter
   End If
End Sub

Do you notice what we've done here within this code? Good...but for those that don't:

Because the frmIndex Form was already opened and populated by way of a Filter string from the frmSearch Form, we use the very same Filter to populate the Report as well. This is done with the DoCmd.OpenReport Function by using the Filter that populated the Form to populate the report.

The conditions set by the IF/THEN statement are mere safety mechanisms so as to prevent any obvious errors.

The Len(Me.Filter) > 0 ensures that there is in fact something (a Filter string) in the frmIndex Form's Filter property.

The Me.RecordsetClone.RecordCount > 0 merely ensures that there are actual records to view within the Report. If there isn't then why bother.

Anyways...you're off to the races.

.
 
CyberLynx
Superb....
Thank you very very much. This is exactly what I had in mind.

Again, my thanks,
SKK
 

Users who are viewing this thread

Back
Top Bottom