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 August 19th, 2012, 07:21 PM
Registered User
 
Join Date: Aug 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Funny Report

Greetings all, I'm Vince and I am new here. I would like to know if anyone can help me with an interesting problem that I am having with one of my reports.

I created a report based on a query that I wrote. The query and report work just fine. I am however trying to fine tune the report. I have added an Overdue label to the report that is normally not visible. I have added several different controls to the form to calculate the DateDiff between when the item was due for calibration and now. The result is either a positive number or negative number which currently show on the report. What I am trying to do is get the "Over Due" label to appear Only for the records where the number of days remaining is less than one. In VBA I wrote some simple code to do this.

Private Sub Report_Load()

If txt_days_remain.Value < 1 Then
lbl_over_due.Visible = True
Else
lbl_over_due.Visible = False
End If

End Sub

The code runs fine and I get the "Over Due" label to appear, but here is the wierd part. If any one of the records has a negative number in the days remaining txt box, then the "Over Due" lable appears for all of the records even if it is not overdue. I am pretty sure that this has something to do with the isolating a record set, but this is something that I haven't figured out how to do just yet. If anyone can help I would appriciate it.
 
Old August 20th, 2012, 04:40 PM
Authorized User
 
Join Date: Oct 2010
Posts: 64
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Hi Vince,

Welcome to the forum.

When you change the visibility of a control on a report, it will affect every detail record within that report. In order to achieve your goal you need to place the code in the OnPrint event of the Detail section.

An easier way to set the Visible property would be as follows:

lbl_over_due.Visible = (txt_days_remain.Value < 1)

No If, Then, Else and End If required!

HTH.

Malc.
 
Old August 20th, 2012, 10:59 PM
Registered User
 
Join Date: Aug 2012
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Malc,
Thanks for the tip. I tried that code and it worked. Now the question is how do I get this into a format that I can add a button or two to send the item to calibration and edit the record. My thought is that I have to pass the tool id to an update query, but here again this is not something that I know how to do just yet. I am wondering if perhaps this process would be simpler to work with a form and add a control to generate the report. The whole idea is a report that will auto run and send the results of the report through an email. If you have any suggestions I would appriciate it.
 
Old August 22nd, 2012, 05:37 PM
Authorized User
 
Join Date: Oct 2010
Posts: 64
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Hi Vince,

I suspect you want the whole process to be initiated by a user? A form with a Command button to run some VBA code via the OnClick event would be ideal.
Use the DoCmd.SendObject command to run the report and email it. What are you wanting to update? Is it different for each record or the same update for a certain selection of records? After the above command a query can be run to perform the necessary updates using either DoCmd.RunSQL or CurrentDb().Execute.

HTH.

Malc.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Funny date return needelp Access VBA 3 September 19th, 2006 11:37 PM
Almost finished helpful code--funny ambrosia Word VBA 2 March 27th, 2006 09:21 PM
User-Level Security Wizard acting funny Bob Bedell Access 1 January 7th, 2006 02:53 AM
funny results.... richjo100 XSLT 3 September 27th, 2004 05:38 AM
Login fail Err when view report on Report Server dillig BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 July 22nd, 2004 05:31 AM





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