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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subform Display Options when Printing 1

Status
Not open for further replies.

ottograham

Technical User
Mar 30, 2001
109
US
I use a scanned image of a 8.5 x 11 insurance application form as a background(unbound image) on which I superimpose my form fields and subforms.

1) Can the subform be set so that it is not transparent (i.e. the background image behind the subform will not appear when printing)? Is so, how?
2) When the number of records exceeds 8, the subform grows too large for the space on the application. How can I test for the number of records, and substitute a text message " See List of Classifications (# exceeds printing space)" where the subform would have been?

As always, thank you in advance for any help you can provide.
 
Make a report based on your form (subform) for printing!

Aivars
 
Dear Aivars:

I saved the form and subform as reports, but the appearance is the same. I think I am missing your point. There must be a way to do this without editing the underlying image, right?

Also, will you address the second part of the question - too many records and the substitution of a text message directing the reader where to look (e.g. "Too many classifications for the space allowed - See the Classification attachment for complete listing of classes")

Thank you for any help you can provide.
 
HI again!

1) Remove picture from report's properties (Report's Properties window; Picture must be shown (none))

2) Set Can Grow = Yes on your subform properties window for display all records of subform.

But I would be developed new report with necessary sub reports for data printing. Work time what is needed for construction of new report is not longer how time for changes after form's saving as report.

Aivars


 
Dear Aivars:

Here's the rub. The background image is a two page image over which there are 4 or 5 subforms and my main form's fields. Reconstructing the image proved a frustrating and time consuming task (there are 20 different applications, with odd fonts, hundreds of little boxes, etc. etc.)

I guess I could edit the image and erase that part of it, but I was hoping for a better solution.

I don't have the option of letting the subform grow because it is a fixed area and will overlap other parts of the form when the record number exceeds 5 (as currently formatted). I want to be able to program the form to:

Case 1 - 5 or fewer records in the subform
Print the subform

Case2 - more than 5 records (which would push the subform into other parts of the form)

Print the message on the form (SEE OTHER REPORT)
Then print a separate report (Setting up this report is not a problem)

I'm sorry if I wasn't clear on the previous posts.

Scott
 
Hi, Scott, again!

Now I have connect to Tek-tips again.
You can write codes in the Detail_Format procedure. See at Help index FormatCount

Good luck!
Aivars
 
A couple of ideas came to mind when I read your question. I haven't actually tried this with a situation like you described, but it would be the first thing I would look at when trying to solve such a problem.

1. Subform backgound not transparent...
If the "form image" is part of your Main Form (not the Sub Form), than you can set the background color for the subform by clicking once in any open area of the subform in design view, select the FORMAT tab in the PROPERTY window, click once in the BACK COLOR property, click on the BUILD icon in right margin of the BACK COLOR property and select whatever color you wish. This will obscure the background image in that portion of the form. (you will probably want to do this for ALL sections of your subform; header, detail, footer, etc)

2. When the number of records exceeds 8...
I have used the following code in one of my own apps to do (precisely) the same thing. I used a temporary table for data entry so that I could manipulate the data that the user was entering without fear (extra coding) of altering any existing data in the tables of saved data (among other things).

"Description" is the FIRST field of the subform record, hence, the test is made immediately upon entry into a new record. "Temp Detail" is the temporary table that the data is being entered into. The "FormTax" field is the NEXT field on the Main Forms following the subform.

Hope this helps...

*******************
Private Sub Description_GotFocus()
Dim dbs As Database, rst As Recordset, cTable As String, nCnt As Integer
Static i As Integer

If i = 0 Then
i = 1
End If
If Me.NewRecord Then
Set dbs = CurrentDb()
cTable = "SELECT * FROM [Temp Detail]"
Set rst = dbs.OpenRecordset(cTable)
rst.MoveLast
nCnt = rst.RecordCount
rst.Close
Set dbs = Nothing
If nCnt = 8 Then
MsgBox "The DPO form is limited to 8 lines.", vbOKOnly, "Ooooops!"
Me.Parent.FormTax.SetFocus
Else
i = i + 1
Me!ItemCnt = i
End If
End If

End Sub
*******************

Dan

P.S. A DLookup function probably would work just as well as a recordset (maybe better, more efficient).
 
Dear Aivars and Dan:

Thanks again for the input.

Aivars - I tried your suggestions, and it didn't seem to work. For simplicity sake, I print right from the form. But I had never looked at FormatCount and its a new concept.

Dan - Your suggestion in the P.S. led me to the solution. On the open event I added the following code where testquery limits the records to the proper account and the "WC" class code and Label19 say "Too many classes - Refer to Schedule":

Dim i As Integer

i = DCount("Account", "testquery")
If i > 4 Then
Child5.Visible = False
Label19.Visible = True


Else
Child5.Visible = True
Label19.Visible = False

End If

Its too easy now that it works! Thanks again for the help.

PS - What is "Static i as Integer"? I'm trying to figure out what the first if block does?
 
When a STATIC variable is declared, unlike other variables, it is initialized with a value automatically. In this case zero, because it is declared as numeric. And (more importantly) it maintains it's value (within the function or sub) for the duration of the form (in this case).

In the example above, the first time the sub is called, "i" is initialized to zero and then the first few lines of code sets it to 1. "i" is used as the item count number for the items listed on the form.

When the next item is created the sub is run for the second time. The STATIC declaration DOES NOT re-initialize the variable. The variable is still there from the first call and still has it's value of 1. Then the code sets it to 2.

...and so on...

The advantage of STATIC vs PUBLIC is that the memory space used by STATIC variables is automatically released when the form is closed, and reinitialized when the form is reopened. PUBLIC of course remains in memory until they are impliedly released or the application is closed.
 
Dan:

Interesting. I need to really look at the code more closely, but I'll assume that the static variable is better than Dim q as Integer (q being a counter).

Do you know much about ActiveX, specifically the Adobe Acrobat component?
 
No, I' sorry. I am still learning Windows programming (MS Access at the moment). All of my experience thus far is from the OLD world. Cobol, Fortran, Apple Basic, IBM Basic, Quick Basic, dBase and Clipper.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top