Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
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 1st, 2006, 05:12 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Corey
Default Would this be a IFF then Statement

Hi again everyone,

I'm stumped again.

I have two reports that my query is looking at.
One is:
1. ProgramActByDay
And the other is:
2. ProgramByProductByDay

What I'm trying to make it do is is to find a cretin program ID then look at a different report and use criteria to populate the sales,

Maybe this will make since

IIF ([Program_ID.ProgramActByDay] = 1667100
Then go to a different report titled: ProgramByProductByDay

And look for
All Program ID = 0
All Product ID = 38648800
All Locale = en_US
Only calculate the data for the current month
Then total all the sales
And put it in the sales field

 
Old November 1st, 2006, 05:27 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Corey
Default

Does this make Sense?

IIF ([Program_ID] = 1667100

Then go to query
ProgramByProductByDay

Field->Program ID = 0
Field->Product ID = 38648800
Field->Locale = en_US
Field->Report_Date = Current Month


Then total all the sales in the Sales Field

Then put the total from the sales back into the
ProgramActByDay query,


 
Old November 2nd, 2006, 09:16 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Hi,

   This sounds like it is the On Click event of a button, and that the user can select Program_ID. If that is the case, and you have a combo box bound to Program_ID, then you can add your conditional logic like this if you are just trying to trap the one Program_ID:

Dim iProgram_ID As Integer 'I am assuming
Dim sDocName As String
Dim sLink As String

iProgram_ID = Me.Program_ID

sLink = "[Program_ID] = " & 0 & " AND [Product_ID] = " & 3864880 & _
        " AND [Locale] = 'en_US'"

If iProgram_ID = 1667100 Then
   sDocName = "ProgramByProductByDay"
Else
   sDocName = "YourOtherReportName"
End If

DoCmd.OpenReport sDocName

I would create a hidden field on your form with the button to launch this report called CurMonth, and put this in the Recordsource: DatePart("m", Date()). Then in your query behind the report, add this line in the criteria section: [Forms]![frmYourFormName].[CurMonth] This will pull data only from the current month. There is a way to do it in the query with fields, but I can't work in Access to figure it out now. This will work.

Then create the calculations on the report. Like add a textbox to the header or footer and enter this in it: =Sum([txtSummedFieldName])

Does this help?

mmcdonal
 
Old November 2nd, 2006, 09:16 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Sorry, add sLink to the DoCmd.OpenReport sDocName statement in the WHERE clause section.

mmcdonal
 
Old November 2nd, 2006, 12:50 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Corey
Default

What if I dont have a form

 
Old November 2nd, 2006, 01:09 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You would attach the code to the event that is running the query. How are you doing that?

mmcdonal
 
Old November 2nd, 2006, 02:40 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 106
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to Corey
Default

I was trying to put it in a Modules, or should I create a form and then hide it

 
Old November 2nd, 2006, 03:18 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You could put this function in a module. How are you going to trigger it?

mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
iff statement not working barmanvarn BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 3 January 23rd, 2009 04:25 PM
IFF () in SQL ayazhoda Access 5 July 17th, 2007 05:52 AM
calculated control box with iff ultimateace Access 3 January 23rd, 2007 08:40 PM
IFF statement in SQL [email protected] SQL Server 2000 1 January 15th, 2007 01:13 PM
Function Iff in VB 6.0 daninoj Beginning VB 6 2 January 17th, 2005 01:06 PM





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