Forum Statistics
- Forum Members:
- Total Threads:
- Total Posts: 6
There are 1 users currently browsing forums.
|
 |

06-25-2009, 05:31 AM
|
|
Registered User
|
|
Join Date: 21 Aug 2008
Location: Gibraltar
MS Office Version:Excel 2007
Posts: 46
|
|
|
Selection to show in Report Page Header
Please Register to Remove these Ads
Hi ... I'm stumped again !
What I want to do is to have the dates that have been inputted on a form, appear in the Report page header.
The form is called Select_Inception. This form only has two text boxes called Start Date and End Date, they select on a field called PeriodFrom. There is also an OK button, this is the vba code I have used
Code:
Private Sub cmdOK_Click()
Dim db As DAO.Database
Dim QD As QueryDef
Dim where As Variant
Set db = CurrentDb()
'Delete the existing dynamic query; trap the error if the query does not exist.
On Error Resume Next
db.QueryDefs.Delete ("Qry_By_Inception_Date")
On Error GoTo 0
If Not IsNull(Me![End Date]) Then
where = where & " AND [PeriodFrom] between DateValue('" + _
Me![Start Date] + "') AND DateValue('" & Me![End Date] & "')"
Else
where = where & " AND [PeriodFrom] >= DateValue('" + Me![Start Date] _
+ "')"
End If
'MsgBox "Select * from Premium " & ("where " + Mid(where, 6) & ";")
Set QD = db.CreateQueryDef("Qry_By_Inception_Date", _
"SELECT * FROM Broker INNER JOIN Premium ON Broker.BrokerNo = Premium.BrokerNo " & (" where " + Mid(where, 6) & ";"))
DoCmd.OpenReport "Premium_by_Inception_Date", acViewPreview
End Sub
I've added a text box in the page header of the report and in the control source i've tried this
Code:
="For the period of" & [Forms]![Select_Inception]![Start Date] & "to" & [Forms]![Select_Inception]![End Date]
But when I open the report I get #Name?
I'm sure it's something daft I'm doing again.
Cheers
Wrightie
Last edited by wrightie; 06-25-2009 at 11:12 AM.
|

06-25-2009, 09:45 AM
|
|
Forum Contributor
|
|
Join Date: 23 Apr 2009
Location: Fredericksburg, IA
MS Office Version:Ultimate 2007
Posts: 126
|
|
|
Re: Selection to show in Report Page Header
Well there are 2 ways to do it, the one I would use is using TempVars.
On the form you enter the dates on make an ok key or something that when clicked does something like:
Code:
Private Sub OK_Click()
Dim MaxBase As Double
Dim MaxCash As Double
Dim MaxEarlyOrder As Double
Dim MaxEarlyShip As Double
Dim MaxProgram As Double
Dim MaxDiscount As Double
MaxBase = Nz(Me.MaxBase, 0)
MaxCash = Nz(Me.MaxCash, 0)
MaxEarlyOrder = Nz(Me.MaxEarlyOrder, 0)
MaxEarlyShip = Nz(Me.MaxEarlyShip, 0)
MaxProgram = Nz(Me.MaxProgram, 0)
MaxDiscount = (1 - MaxBase) * (1 - MaxCash) * (1 - MaxEarlyOrder) * (1 - (MaxEarlyShip + MaxProgram))
TempVars.Add "MaxBase", MaxBase
TempVars.Add "MaxCash", MaxCash
TempVars.Add "MaxEarlyOrder", MaxEarlyOrder
TempVars.Add "MaxEarlyShip", MaxEarlyShip
TempVars.Add "MaxProgram", MaxProgram
TempVars.Add "MaxSeedTenderDiscount", MaxDiscount
Me.Visible = False
End Sub
Then in the 2 text fields you enter the following in the control source: =[TempVars]![MaxBase] etc
These are examples from my database. I use the discounts in the header of a report comparing pricing.
If the form is still open when you open the report you can always use the "me."
Hope this helps,
Dan
P.S. TempVars only works in Access 2007, (I see you have excel 2007 so assumed.)
__________________
"I am not a rocket scientist, I am a nuclear engineer." - Split_atom18
If my advice has been helpful to you, then please help me by clicking on the scales and adding to my reputation, Thanks!
|

06-25-2009, 09:56 AM
|
|
Registered User
|
|
Join Date: 21 Aug 2008
Location: Gibraltar
MS Office Version:Excel 2007
Posts: 46
|
|
|
Re: Selection to show in Report Page Header
Hi Dan ,
We are on MS 2007 Basic, so for the time being still using Access 2003.
However I will keep this info for when we get round to upgrading, so thanks for that.
I don't suppose you have a 2003 option ?
wrightie
|

06-25-2009, 11:03 AM
|
|
Registered User
|
|
Join Date: 21 Aug 2008
Location: Gibraltar
MS Office Version:Excel 2007
Posts: 46
|
|
|
Re: Selection to show in Report Page Header
I've tried this and get the text "For the period of to" . No error message so it's a tad better !
="For the period of" & Forms!Select_Inception![Start Date] & " to" & Forms!Select_Inception![End Date]
|

06-25-2009, 11:12 AM
|
|
Registered User
|
|
Join Date: 21 Aug 2008
Location: Gibraltar
MS Office Version:Excel 2007
Posts: 46
|
|
|
Re: Selection to show in Report Page Header
Yep it worked. This code was ok, i just hadn't placed any dates in the form hence why it was just bringing up only the text.
="For the period of" & Forms!Select_Inception![Start Date] & " to" & Forms!Select_Inception![End Date]
Thanks yet again Dan for you help, I will remember the TempVars for when we upgrade to pro.
Cheers
wrightie
|

06-25-2009, 01:02 PM
|
|
Forum Contributor
|
|
Join Date: 23 Apr 2009
Location: Fredericksburg, IA
MS Office Version:Ultimate 2007
Posts: 126
|
|
|
Re: Selection to show in Report Page Header
Np, glad you figured it out.
TempVars are a fantastic addition.
__________________
"I am not a rocket scientist, I am a nuclear engineer." - Split_atom18
If my advice has been helpful to you, then please help me by clicking on the scales and adding to my reputation, Thanks!
|
 |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Rate This Thread |
Linear Mode
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|