PDA

View Full Version : Timer problem!!1



slchslch
09-18-2005, 07:49 PM
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??.....http://vbaexpress.com/forum/images/smilies/banghead.gifhttp://vbaexpress.com/forum/images/smilies/banghead.gifhttp://vbaexpress.com/forum/images/smilies/banghead.gif....please help here...really urgent..

thanks for reading....

geekgirlau
09-19-2005, 02:30 AM
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?

slchslch
09-19-2005, 06:25 PM
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!http://vbaexpress.com/forum/images/smilies/cool.gif

xCav8r
09-19-2005, 06:41 PM
Can we see a code snippet? I think you're telling it to print the form instead of to print the report:
DoCmd.OpenReport "MyReportsName", acNormal

slchslch
09-19-2005, 07:12 PM
Can we see a code snippet? I think you're telling it to print the form instead of to print the report:
DoCmd.OpenReport "MyReportsName", acNormal

this is the way i generate report

DoCmd.OpenReport stDocName, acViewPreview, , , acWindowNormal

xCav8r
09-19-2005, 07:16 PM
But that won't automatically print the report. Where's the code for that?

slchslch
09-19-2005, 07:17 PM
But that won't automatically print the report. Where's the code for that?


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


this is my print function...

xCav8r
09-19-2005, 07:24 PM
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. ;)

slchslch
09-19-2005, 07:34 PM
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....

xCav8r
09-19-2005, 07:48 PM
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.

slchslch
09-19-2005, 08:08 PM
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....http://vbaexpress.com/forum/images/smilies/think.gif

xCav8r
09-19-2005, 08:09 PM
only way for me to say for sure is to see your event procedure ;)