Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing Inputbox to text field on a Report

Status
Not open for further replies.

freefour

MIS
Aug 26, 2004
33
US
On one of my forms, you click a button that launches my ReportSales report. Using inputbox, it asks for a begin date then a end date. I want to pass those dates entered into my report as well (so it can remind them what the criteria was set at): Here is my code:


Dim Message, Title, Default, MyValue, FirstDate, SecondDate, message2
Dim stlinkcriteria As String

Message = "Enter First Date:"
Message2 = "Enter Last Date:"
Title = "Select Dates" ' Set title.
Default = Date
FirstDate = InputBox(Message, Title, Default)
SecondDate = InputBox(Message2, Title, Default)
stlinkcriteria = "[Date]>=" & "#" & FirstDate & "#" & " AND [DATE] <=" & "#" & SecondDate & "#"


Dim stDocName As String

stDocName = "ReportSales"
DoCmd.OpenReport stDocName, acPreview, , stlinkcriteria

Report_ReportSales.txtbegindate.Value = FirstDate
Report_ReportSales.txtenddate.Value = SecondDate


The last two line does not work. It doesn't pass anything. I need to pass the inputbox's values into the fields on my report. Can someone tell me what I am doing wrong?

Thanks!

--freefour
 
Though I'm more into "pulling" information than "pushing", you could try using the ordinary syntax:

[tt]Reports!ReportSales!txtbegindate=...
Reports("ReportSales")("txtbegindate")=...' or even
Reports(stDocName)("txtbegindate")=...[/tt]

Else, my usual approach, whould be to pull this information from text controls on the form. The form needs to be open, but you could just do a me.visible=false when opening the report.

And I don't particularly like inputboxes, cause you can't do any datavalidation there, as you can do thru input mask on form controls...

Roy-Vidar
 
Thanks Roy, but after trying all three I still get the same result: nothing. txtbegindate is an unbounded textbox.

I am curious is there a better way of maybe having 2 boxes on the report that people put the two boxes where they could change the dates and then the report would change to reflect the new begin and end dates?

I still wonder what I am doing wrong.
 
Pull the information from the report - as said, have textcontrols on the form where you input (and validate) the dates (use the same name as on the report?), then use something like this as controlsource of one of the text controls on the report:

[tt]=forms!NameOfForm!txtBeginDate[/tt]

- alter the form name

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top