D
Derek Wittman
Good morning,
I have functions that request the business Year and business Period
that the user wants reported. From there, the query runs with that
criteria. The criteria apply to either Request_Date or Complete_Date.
My problem is that the inputbox is coming up twice. What do I need
to do to make it 'save' the value for all calls of the PeriodStart()
function? Code below. Yes, I know I named things without
consideration for appropriate naming practices.
Thanks!
Derek
Option Compare Database
Public Function Busyear() As Integer
Busyear = InputBox("Please enter the YEAR you'd like to examine
(XXXX):")
End Function
Public Function Period() As Integer
Period = InputBox("Please enter the PERIOD you'd like to examine
(XX):")
End Function
Public Function PeriodStart() As Variant
PeriodStart = DLookup("[Start Date]", "Period History", "[Fiscal
Year] = Busyear()") + (Period() - 1) * 28 'watch the wordwrap
MsgBox ("The Period Start Date is:" & PeriodStart)
End Function
SQL for the Query
SELECT [Standards Update Log].[Control Number], [Standards Update
Log].Division, [Standards Update Log].[Date Requested], [Standards
Update Log].Department, [Standards Update Log].[Operation ID],
[Standards Update Log].AislesLevel, [Standards Update Log].[Old
Standard], [Standards Update Log].[New Standard], [Standards Update
Log].[Date Completed]
FROM [Standards Update Log], [Period History]
GROUP BY [Standards Update Log].[Control Number], [Standards Update
Log].Division, [Standards Update Log].[Date Requested], [Standards
Update Log].Department, [Standards Update Log].[Operation ID],
[Standards Update Log].AislesLevel, [Standards Update Log].[Old
Standard], [Standards Update Log].[New Standard], [Standards Update
Log].[Date Completed], Year([Date Requested]), IIf(Year([Date
Requested])=2003,Int(([Date Requested]-#2/2/2003#)/28)+1,Int(([Date
Requested]-#1/5/2004#)/28)+1), Year([Date Completed]), IIf(Year([Date
Completed])=2003,Int(([Date Completed]-#2/2/2003#)/28)+1,Int(([Date
Completed]-#1/5/2004#)/28)+1)
HAVING (((Year([Date Requested]))=busyear()) AND ((IIf(Year([Date
Requested])=2003,Int(([Date Requested]-#2/2/2003#)/28)+1,Int(([Date
Requested]-#1/5/2004#)/28)+1))=period())) OR (((Year([Date
Completed]))=busyear()) AND ((IIf(Year([Date
Completed])=2003,Int(([Date Completed]-#2/2/2003#)/28)+1,Int(([Date
Completed]-#1/5/2004#)/28)+1))=period()));
I have functions that request the business Year and business Period
that the user wants reported. From there, the query runs with that
criteria. The criteria apply to either Request_Date or Complete_Date.
My problem is that the inputbox is coming up twice. What do I need
to do to make it 'save' the value for all calls of the PeriodStart()
function? Code below. Yes, I know I named things without
consideration for appropriate naming practices.
Thanks!
Derek
Option Compare Database
Public Function Busyear() As Integer
Busyear = InputBox("Please enter the YEAR you'd like to examine
(XXXX):")
End Function
Public Function Period() As Integer
Period = InputBox("Please enter the PERIOD you'd like to examine
(XX):")
End Function
Public Function PeriodStart() As Variant
PeriodStart = DLookup("[Start Date]", "Period History", "[Fiscal
Year] = Busyear()") + (Period() - 1) * 28 'watch the wordwrap
MsgBox ("The Period Start Date is:" & PeriodStart)
End Function
SQL for the Query
SELECT [Standards Update Log].[Control Number], [Standards Update
Log].Division, [Standards Update Log].[Date Requested], [Standards
Update Log].Department, [Standards Update Log].[Operation ID],
[Standards Update Log].AislesLevel, [Standards Update Log].[Old
Standard], [Standards Update Log].[New Standard], [Standards Update
Log].[Date Completed]
FROM [Standards Update Log], [Period History]
GROUP BY [Standards Update Log].[Control Number], [Standards Update
Log].Division, [Standards Update Log].[Date Requested], [Standards
Update Log].Department, [Standards Update Log].[Operation ID],
[Standards Update Log].AislesLevel, [Standards Update Log].[Old
Standard], [Standards Update Log].[New Standard], [Standards Update
Log].[Date Completed], Year([Date Requested]), IIf(Year([Date
Requested])=2003,Int(([Date Requested]-#2/2/2003#)/28)+1,Int(([Date
Requested]-#1/5/2004#)/28)+1), Year([Date Completed]), IIf(Year([Date
Completed])=2003,Int(([Date Completed]-#2/2/2003#)/28)+1,Int(([Date
Completed]-#1/5/2004#)/28)+1)
HAVING (((Year([Date Requested]))=busyear()) AND ((IIf(Year([Date
Requested])=2003,Int(([Date Requested]-#2/2/2003#)/28)+1,Int(([Date
Requested]-#1/5/2004#)/28)+1))=period())) OR (((Year([Date
Completed]))=busyear()) AND ((IIf(Year([Date
Completed])=2003,Int(([Date Completed]-#2/2/2003#)/28)+1,Int(([Date
Completed]-#1/5/2004#)/28)+1))=period()));