Results 1 to 5 of 5

Thread: OK Button

  1. #1
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271

    Question Unanswered: OK Button

    I designed a form (SalesReportFrm) to open a sales report. I put 2 unbound text boxes for the date beginning and ending. What code do I need to write and where do I put the code, to open the sales report (2004SalesRpt) and enter these dates in the proper place?

    I do have in the report's query already under the invoice date field:
    Is Not Null And Between [Forms]![SalesReportFrm]![BeginningDate] And [Forms]![SalesReportFrm]![EndingDate]

    Thank You for any help
    Gotta to do some code

  2. #2
    Join Date
    Mar 2004
    Location
    Brighton, UK
    Posts
    25
    On the onclick event for the button you need to put some vba code - to do this go to the Event properties for the button, choose [Event Procedure] and click the ... button. In the code here you need

    DoCmd.OpenReport "MyReportName", acViewPreview

    (assuming you want to preview it)

    In the report itself you need a text box, and to set the control source for the text box to be eg

    ="Date From " & IIf([Forms]![SalesReportFrm]![BeginningDate] Is Null,"Any",Format([Forms]![SalesReportFrm]![BeginningDate],"dd-mmm-yyyy")) & " to " & IIf([Forms]![SalesReportFrm]![EndingDate] Is Null,"Any",Format([Forms]![SalesReportFrm]![EndingDate],"dd-mmm-yyyy"))

    Of course it doesn't need to be that complicated, you could just have one text box with

    = "From " & [Forms]![SalesReportFrm]![BeginningDate]

    and another for the other date.

    You might want to adjust your query though for the case where the user doesn't enter a date (ie assume all dates are fine), by having criteria:

    Between IIf([Forms]![SalesReportFrm]![BeginningDate] Is Null,#01/01/1990#,[Forms]![SalesReportFrm]![BeginningDate]) And IIf([Forms]![SalesReportFrm]![EndingDate] Is Null,#01/01/2028#,[Forms]![SalesReportFrm]![EndingDate])

    Hope this is of help

  3. #3
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271
    If I put this code:
    = "From " & [Forms]![SalesReportFrm]![BeginningDate]
    in my unbound form, This should enter the data?

    Surf
    Gotta to do some code

  4. #4
    Join Date
    Mar 2004
    Location
    Adelaide, Australia
    Posts
    32
    I recently created reporting functionality for a DB I created for a client.

    They click on a button to display a Reports Menu form. Here they select the report they want and enter criteria (dates and other fields) and select preview.

    The selected report object then opens, and in the Report_Open event, I build an SQL string and assign it to the reports recordsource.

    A bit of coding but very effective.

    Attached is a demo I found somewhere that helped with the development of my interface.

    HTH.
    Attached Files Attached Files

  5. #5
    Join Date
    Mar 2004
    Location
    Greenville, SC
    Posts
    271

    Thank You

    I will review what you have sent. I am not very good or comfortable with code right now.

    Rocket71 I appreciate the help on the last tip also. I was going to Personal Message you but I see you don't except PIM's.

    Thank You, you have been a lot of help.
    Gotta to do some code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •