Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

VBA Access Woes with report

wadetwadet Posts: 1Member
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

  • PavlinIIPavlinII Posts: 404Member
    : 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
    :
    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]


Sign In or Register to comment.