Results 1 to 5 of 5

Thread: input data

  1. #1
    Join Date
    Mar 2004
    Posts
    660

    Unanswered: input data

    Hello, i have 4 reports, users would like to print them all at one time. All of these reports need to enter date first. I can create a form that has date field to let use enter the date. Do you have any other method to do it? Just like messgagebox to let user enter the date and then retrieve this date for each report? So i don't need to create another form. Thanks.

  2. #2
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    I always make sure to enter necessary date or other entries from a form so I can perform data testing (how do I know the user won't enter "Hello" when a date is required). It's not pleasant when Access does the testing for you and then the program bombs. Also, I include in the coding the ability to choose the output, whether to screen or to print (I use an option group for that). Personally, I never print reports to the printer directly. Just in case, I want to print to screen and have the ability to kill it and rerun - or reprogram - it.

    It may sound hifalutin, but I consider it self-preservation.

    Sam

  3. #3
    Join Date
    Mar 2004
    Posts
    660
    Now i create a form, but it didn't work,

    Dim enterdate As Date
    enterdate = CDate(Me.txtReceiptDate)
    DoCmd.OpenReport "rptReport", acNormal, , "[ReceiptDate]=" & enterdate

    when it print, it didn't print any record. Could you please help?

  4. #4
    Join Date
    May 2004
    Location
    New York State
    Posts
    1,178
    Change

    Code:
    DoCmd.OpenReport "rptReport", acNormal, , "[ReceiptDate]=" & enterdate
    to

    Code:
    DoCmd.OpenReport "rptReport", acNormal, , "[ReceiptDate]= #" & enterdate & "#"
    I'm assuming that the code you posted is in the txtReceiptDate.AfterUpdate() event. If it's not there, for instance if you have a separate command button to generate the report, you need to disable the command button until after updating the txtReceiptDate text box. That way you force the user to input a date before trying to generate the report. BTW, I would put some testing code to make sure it's really a date, within the range of reality, etc., etc.

    Sam

  5. #5
    Join Date
    Mar 2004
    Posts
    660
    Quote Originally Posted by Sam Landy
    Change

    Code:
    DoCmd.OpenReport "rptReport", acNormal, , "[ReceiptDate]=" & enterdate
    to

    Code:
    DoCmd.OpenReport "rptReport", acNormal, , "[ReceiptDate]= #" & enterdate & "#"
    I'm assuming that the code you posted is in the txtReceiptDate.AfterUpdate() event. If it's not there, for instance if you have a separate command button to generate the report, you need to disable the command button until after updating the txtReceiptDate text box. That way you force the user to input a date before trying to generate the report. BTW, I would put some testing code to make sure it's really a date, within the range of reality, etc., etc.

    Sam
    Thanks for this. You are right. I use button click event. After click the report button, i am going check the date before generating the report. Thank you very much!

Posting Permissions

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