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 November 30th, 2005, 07:59 AM
Registered User
 
Join Date: Jan 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help needed with report

I am trying to create a report but need help with one aspect.

There are two fields - Programmed Commencement Date and Actual Commencement Date. I want the query/report to show the Actual Commencement Date but sometimes this is null and the Programmed Commencement Date needs to show in the report.

What I really need is very basic instructions on this as I'm fairly new to databases and don't have much SQL experience.

Please help!
 
Old November 30th, 2005, 09:07 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hi,

   Put both fields on the report, and set them both to visible = No. Lay them right on top of each other.

Then put code in the Details On Format event like this:

Me.Actual Commencement Date.Visible = False
Me.Programmed Commencement Date.Visible = False

If IsNull(Me.Actual Commencement Date) Then
   Me.Programmed Commencement Date.Visible = True
   Else
   Me.Actual Commencement Date.Visible = True
End If

If your report is not too large (many hundreds of records) this will work pretty quickly.

P.S. Those are bad field names. They should be something like:
ProgCommDate
ActCommDate
with Captions that have the full name. This code may be kludgy since there are spaces in the field names. A big no-no. Date is also a reserved name, so be careful.

HTH



mmcdonal
 
Old November 30th, 2005, 10:54 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,151
Thanks: 2
Thanked 14 Times in 14 Posts
Send a message via ICQ to SerranoG Send a message via AIM to SerranoG
Default

Another approach would start with you putting both dates and making them invisible like mmcdonal said, but then leave them be. Put a third visible, but UNbound, textbox (call it, say CommencementDate) on there and in the report's detail section's ON FORMAT event you put this simple one line.

Me.CommencementDate = Nz(Me.[Acutal Commencement Date], Me.[Me.Programmed Commencement Date])

You can also forget the ON FORMAT event code and put

= Nz(Me.[Acutal Commencement Date], Me.[Me.Programmed Commencement Date])

directly into the textbox's controlsource in the report's design view.


Greg Serrano
Michigan Dept. of Environmental Quality, Air Quality Division
 
Old November 30th, 2005, 10:57 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I love finding more elegant ways to do things on this site. I like the last one best as it is probably the fastest.

mmcdonal
 
Old November 30th, 2005, 12:54 PM
Registered User
 
Join Date: Jan 2005
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks to both of you for your help - I'll go and test it out!






Similar Threads
Thread Thread Starter Forum Replies Last Post
simple report and crystal report in vb.net saket123 .NET Framework 2.0 0 August 13th, 2008 06:55 AM
help needed........ Regarding jasper report gita_Sathyam Java Basics 2 June 19th, 2008 05:20 AM
What Dll is needed to pdf a crystal report frm vb6 daniel_arney Pro VB 6 3 September 25th, 2006 02:08 PM
doubt in crystal report(help needed Urgently) ramya_c2004 Crystal Reports 0 December 14th, 2004 01:41 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.