Howdy, Stranger!

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

Categories

code for print specific report

nabilahnabilah Member Posts: 16
how can i code to print the specific report according to input box?

Comments

  • dokken2dokken2 Member Posts: 532
    : how can i code to print the specific report according to input box?
    :
    Dim rpt As String
    rpt = InputBox("Report name?")
    DoCmd.OpenReport rpt, acViewNormal

  • splansingsplansing Member Posts: 140
    : : how can i code to print the specific report according to input box?
    : :
    : Dim rpt As String
    : rpt = InputBox("Report name?")
    : DoCmd.OpenReport rpt, acViewNormal
    :
    :
    That requires your users to know the names of your reports. Build a form that has a drop-down list on it. Create a table with two columns: ReportName and DisplayName. The report name is the actual name of the report within your database, which probably doesn't mean a whole lot to the user. The display name is the title of the report, as you want the users to see it.

    Use the table as the rowsource for a drop-down box, but hide the column with the actual name of the report in it. When the user selects a report title from the list, you open the report by looking at the value in the hidden column. If you want to, you can make this a pop-up form that you can call from anywhere within your database. Additionally, you can add columns to the table that will allow you to categorize your reports, so you can tell the form upon opening which group of reports you want to appear in the drop-down box.

    In this way, you can give yourself a tremendous amount of flexibility, keep the interface consistent for all of your reporting functions, and if you change report names or add or remove reports, all you have to do is add/remove/change the corresponding record in your table. The setup time will pay for itself almost immediately; it shouldn't take too long to get it working.
  • nabilahnabilah Member Posts: 16
    : : : how can i code to print the specific report according to input box?
    : : :
    : : Dim rpt As String
    : : rpt = InputBox("Report name?")
    : : DoCmd.OpenReport rpt, acViewNormal
    : :
    : :
    : That requires your users to know the names of your reports. Build a form that has a drop-down list on it. Create a table with two columns: ReportName and DisplayName. The report name is the actual name of the report within your database, which probably doesn't mean a whole lot to the user. The display name is the title of the report, as you want the users to see it.
    :
    : Use the table as the rowsource for a drop-down box, but hide the column with the actual name of the report in it. When the user selects a report title from the list, you open the report by looking at the value in the hidden column. If you want to, you can make this a pop-up form that you can call from anywhere within your database. Additionally, you can add columns to the table that will allow you to categorize your reports, so you can tell the form upon opening which group of reports you want to appear in the drop-down box.
    :
    : In this way, you can give yourself a tremendous amount of flexibility, keep the interface consistent for all of your reporting functions, and if you change report names or add or remove reports, all you have to do is add/remove/change the corresponding record in your table. The setup time will pay for itself almost immediately; it shouldn't take too long to get it working.
    :

    if i wish to print report for one staff,how i can do that?let's say that i have thousand or hundred of staff.do i need to prepare a report for each staff and just call in input box or can i put sql statement
    after the code for DoCmd.OpenReport rpt,acViewNormal according to user input in input box.
  • dokken2dokken2 Member Posts: 532
    : if i wish to print report for one staff,how i can do that?let's say that i have thousand or hundred of staff.do i need to prepare a report for each staff and just call in input box or can i put sql statement
    : after the code for DoCmd.OpenReport rpt,acViewNormal according to user input in input box.
    :

    Filter the report with a where condition to restrict the records to a few or even just one-

    Dim MyName As String
    MyName = InputBox("Staff name?")
    'enclose string within single-quotes
    MyName = Chr(39) & MyName & Chr(39)
    DoCmd.OpenReport "MyReport", acViewNormal, , "[ReportFieldName]=" & MyName

  • nabilahnabilah Member Posts: 16
    : : if i wish to print report for one staff,how i can do that?let's say that i have thousand or hundred of staff.do i need to prepare a report for each staff and just call in input box or can i put sql statement
    : : after the code for DoCmd.OpenReport rpt,acViewNormal according to user input in input box.
    : :
    :
    : Filter the report with a where condition to restrict the records to a few or even just one-
    :
    : Dim MyName As String
    : MyName = InputBox("Staff name?")
    : 'enclose string within single-quotes
    : MyName = Chr(39) & MyName & Chr(39)
    : DoCmd.OpenReport "MyReport", acViewNormal, , "[ReportFieldName]=" & MyName
    :
    :
    I've already have a code for print according month and name.my question is,can i put this two code together and how can i use the if...else statement if i want to do that?thanks.
  • splansingsplansing Member Posts: 140
    : : : if i wish to print report for one staff,how i can do that?let's say that i have thousand or hundred of staff.do i need to prepare a report for each staff and just call in input box or can i put sql statement
    : : : after the code for DoCmd.OpenReport rpt,acViewNormal according to user input in input box.
    : : :
    : :
    : : Filter the report with a where condition to restrict the records to a few or even just one-
    : :
    : : Dim MyName As String
    : : MyName = InputBox("Staff name?")
    : : 'enclose string within single-quotes
    : : MyName = Chr(39) & MyName & Chr(39)
    : : DoCmd.OpenReport "MyReport", acViewNormal, , "[ReportFieldName]=" & MyName
    : :
    : :
    : I've already have a code for print according month and name.my question is,can i put this two code together and how can i use the if...else statement if i want to do that?thanks.
    :
    It sounds like all you need to do is build a slightly more complex WHERE statement, using AND to join a whatever conditions you want to impose on the report.
Sign In or Register to comment.