Consulting

Results 1 to 12 of 12

Thread: Timer problem!!1

  1. #1
    VBAX Regular
    Joined
    Jun 2005
    Posts
    30
    Location

    Timer problem!!1

    Dear all,
    I have a startup form in Access with On Timer event..which will auto refresh my data source every timer interval...but when i try to print some reports, its come out the result that the startup form will be printed instead of te report itself.?....WHY???...is that because of the form still dum in the memory or??.........please help here...really urgent..

    thanks for reading....

  2. #2
    Moderator VBAX Master geekgirlau's Avatar
    Joined
    Aug 2004
    Location
    Melbourne, Australia
    Posts
    1,464
    Location
    Why do you need to refresh the data source in this way?
    What is the data source of the startup form?
    How are you generating the report?
    What is the data source of the report?

  3. #3
    VBAX Regular
    Joined
    Jun 2005
    Posts
    30
    Location
    ekk...i think i make a mistake here..i shoud said that its not a data source...it's row source...actually i has a listbox in my startup form which will display my outstanding workorder ..i need to update the row source to display the updated outstanding workorder....

    By right, i used the On Timer event to do it..its work for me..but when i try to print some report out, its come out the result that the active form will be printing...which is the startup form will be printing...

    i generate my report using queries....and using acCmdPrint run command to prompt out the print dialog box!

  4. #4
    VBAX Expert xCav8r's Avatar
    Joined
    May 2005
    Location
    Minneapolis, MN, USA
    Posts
    912
    Location
    Can we see a code snippet? I think you're telling it to print the form instead of to print the report:
    [VBA] DoCmd.OpenReport "MyReportsName", acNormal[/VBA]

  5. #5
    VBAX Regular
    Joined
    Jun 2005
    Posts
    30
    Location
    Quote Originally Posted by xCav8r
    Can we see a code snippet? I think you're telling it to print the form instead of to print the report:
    [VBA] DoCmd.OpenReport "MyReportsName", acNormal[/VBA]
    this is the way i generate report
    [VBA]
    DoCmd.OpenReport stDocName, acViewPreview, , , acWindowNormal
    [/VBA]

  6. #6
    VBAX Expert xCav8r's Avatar
    Joined
    May 2005
    Location
    Minneapolis, MN, USA
    Posts
    912
    Location
    But that won't automatically print the report. Where's the code for that?

  7. #7
    VBAX Regular
    Joined
    Jun 2005
    Posts
    30
    Location
    Quote Originally Posted by xCav8r
    But that won't automatically print the report. Where's the code for that?
    [VBA]
    Public Function PrintOut()

    On Error GoTo ErrorTrap

    DoCmd.RunCommand acCmdPrint
    Exit Function

    ErrorTrap:
    If err.Number = 2501 Then
    Exit Function
    Else
    MsgBox err.Number & vbCrLf & err.Description
    End If

    End Function
    [/VBA]

    this is my print function...

  8. #8
    VBAX Expert xCav8r's Avatar
    Joined
    May 2005
    Location
    Minneapolis, MN, USA
    Posts
    912
    Location
    Which module? The one for the timer form? If so, that's why it's printing the form. Try swapping the code for what I wrote above.

  9. #9
    VBAX Regular
    Joined
    Jun 2005
    Posts
    30
    Location
    Quote Originally Posted by xCav8r
    Which module? The one for the timer form? If so, that's why it's printing the form. Try swapping the code for what I wrote above.
    nono..the printing function is not under the form module....i actually create a toolbar button specially for print function...and i assign the button action to the print function.......

    ya i know your code work perfectly...but how if the user like to select different printer instead of printed to the default printer....

    previously i have tried using debug.print....and using docmd.selected object command to selected the report itself....its work also ..but lack of user friendly...i want somethign similar to print dialog box when i call accmdprint command....

  10. #10
    VBAX Expert xCav8r's Avatar
    Joined
    May 2005
    Location
    Minneapolis, MN, USA
    Posts
    912
    Location
    Okay, something must be giving the form that's being printed the focus, since accmdprint and printout print the selected object. That's problem one, but I don't have enough info to know what's making that happen.

    The second issue is the print dialog box. The easiest solution to me seems to use the existing print command from the file menu when the report is previewed. Alternatively, you could build your own print dialog. There's a lot of information in the help documentation on printers, and I've got some helpful links from the MSDN library if you would like them.

  11. #11
    VBAX Regular
    Joined
    Jun 2005
    Posts
    30
    Location
    Quote Originally Posted by xCav8r
    Okay, something must be giving the form that's being printed the focus, since accmdprint and printout print the selected object. That's problem one, but I don't have enough info to know what's making that happen.

    The second issue is the print dialog box. The easiest solution to me seems to use the existing print command from the file menu when the report is previewed. Alternatively, you could build your own print dialog. There's a lot of information in the help documentation on printers, and I've got some helpful links from the MSDN library if you would like them.
    hmm..do you think this problem is affected by On Timer event?...cause previously i have tried to disable the On Timer function, and finally its back to normal, when the On Timer event on back, problem occur....my startup form and the form which i generate the report is seperate 1....

  12. #12
    VBAX Expert xCav8r's Avatar
    Joined
    May 2005
    Location
    Minneapolis, MN, USA
    Posts
    912
    Location
    only way for me to say for sure is to see your event procedure

Posting Permissions

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