Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 14th, 2006, 09:09 PM
Authorized User
 
Join Date: Oct 2006
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default visibility dynamic in report

Hello all,
I've got a report I have setup to create labels. In the detail section I have 4 text boxes setup as following:
'''''''''Device Header''''''''''''''''''''''''''''''
Name
Location
Text1
text2
'''''''''Detail''''''''''''''''''''''''''''''''''' ''
text3
text4
Text5
Text6

I'm trying to change the visibility dynamically (based on the entries). Basically if IsNull([Text1]) = True I want to make
Detail.Visibility = False but that should be different for each entry. There are three columns per page with 9 possible Device headers (if detail section is empty). I tried using the can shrink property but the problem I come up with is if I have data in text3 and text4 but not text5 and text6 then it shifts the next Device Header up (not good for printing labels). Bottom line. If I have text in text3 I need text4, text5, and text6 to not shrink, but if no text in Text3 to shrink the entire section. I tried to use this code:

Set db = CurrentDb()
Set rst = db.OpenRecordset("Main", dbOpenDynaset)
If (IsNull(rst![Tag2]) And IsNull(rst![Tag3])) Then
    Detail.Visible = False
Else
    Detail.Visible = True
End If
rst.MoveNext

in the code window but it will only run at startup, not per row accessed from the table. Any ideas how to make that code get accessed for each record and make the detail section react dynamically?

Thanks in advance!

 
Old December 15th, 2006, 02:46 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Refine your query behind the report.

Add this code to the criteria line in your query for the Text3 field:

<>""

Of course, this will also remove the information for Name, Location, Text1 and Text2.

Create two queries then. One with Name, Location, Text1, Text2.
Then create a second query with the balance of the table using Text3, Text4, Text5, Text6. Then add the first query, link them by the proper field (must be in both queries) and then modify the relationship to show all records in the first query even if there are no matching records in the other table.

Then create the report and put all the data in the Detail section:

Detail:
Name
Location
Text1
Text2
Text3
Text4
Text5
Text6

Then on the detail section's on format event, set the width of the controls to 0 if Text3 is null or blank, and back to whatever it should be (in twips) if it has a value. If this doesn't work, then make them move up a few lines if 3 is blank and make them invisible.

Like that.

I guess there is a better way by removing the controls if 3 is empty.

You might make two reports based on two queries, one with Text3 having a value, and one without. That is the bullet proof way.

Hope this gives you some ideas.

mmcdonal
 
Old December 18th, 2006, 06:19 PM
Authorized User
 
Join Date: Oct 2006
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It Does indeed. Thanks mmcdonal :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Report DARSIN Crystal Reports 2 January 21st, 2006 04:52 AM
Dynamic report pawa Crystal Reports 0 September 22nd, 2005 11:44 PM
Dynamic Report Design echovue Access 1 August 8th, 2005 02:40 AM
Dynamic crystal report n_alavii Crystal Reports 0 May 11th, 2005 04:56 AM
Dynamic crystal report n_alavii Crystal Reports 0 May 11th, 2005 04:54 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.