Ok..have kicked the cat, bit the dog, smoked 2 pks of cigarettes and pulled my hair out trying to find the solution to this class assignment.
Here is the problem: wish to sort and view report using the input search criteria by user (1 string, 1 date). There are 3 areas to search for each date Ordered, Required or Promised. The out put is to be a report that only the records whose order date is X
Here is what I got so far.
Public Function PrintReport()
'assign variables and address to variable object
Dim strField As String, strDate As String, dtmDate As Date, rptOrdersReport As Report
'open report
DoCmd.OpenReport ("ordersreport"), acViewPreview
'set the open report as active
Set rptOrdersReport = Application.Reports("ordersreport")
'input from user
strField = InputBox(prompt:="What field do you wish to view: ", Default:="Ordered")
strDate = InputBox(prompt:="What date do wish to view: ", Default:=Date)
'search by variables input by user
????????????? instructor desires us to use the wherecondition, concatenation and # signs around the date input by the user.
End Function
I'm sure I am looking right at it but can't see the solution and it is driving me buggy.
Any help would be appreciated greatly.
TIA,
Wade
Comments
:
: Here is the problem: wish to sort and view report using the input search criteria by user (1 string, 1 date). There are 3 areas to search for each date Ordered, Required or Promised. The out put is to be a report that only the records whose order date is X
:
: Here is what I got so far.
: Public Function PrintReport()
: 'assign variables and address to variable object
: Dim strField As String, strDate As String, dtmDate As Date, rptOrdersReport As Report
: 'open report
: DoCmd.OpenReport ("ordersreport"), acViewPreview
: 'set the open report as active
: Set rptOrdersReport = Application.Reports("ordersreport")
: 'input from user
: strField = InputBox(prompt:="What field do you wish to view: ", Default:="Ordered")
: strDate = InputBox(prompt:="What date do wish to view: ", Default:=Date)
: 'search by variables input by user
:
: ????????????? instructor desires us to use the wherecondition, concatenation and # signs around the date input by the user.
:
: End Function
:
: I'm sure I am looking right at it but can't see the solution and it is driving me buggy.
:
: Any help would be appreciated greatly.
:
: TIA,
:
: Wade
:
Hi,
DoCmd has more than 2 parameters and one of them is for criteria!
You should ask for criteria first, and then open the report. If you need to "preview" the report to user, before he/she chooses one, close the old and open new one.
DoCmd.OpenReport "rDluhyCk", acViewPreview ,,"Put your criteria here"
DoCmd.OpenReport "rDluhyCk", acViewPreview ,WhereCondition:="Put your criteria here"
Theese two line are equivalent.
DoCmd.OpenReport "rDluhyCk", acViewPreview ,,strfield & "#" & strDate & "#"
should work "#" is there because of the Date datatype. But you should verify, if user really input date, before passing it into DoCmd.
Hope this helps
[blue][b][italic][size=4]P[/size]avlin [size=4]II[/italic][/size][/b][/blue]
[purple]Don't take life too seriously anyway you won't escape alive from it![/purple]