Hi, Im trying to call the same report several times in VB using a global variable to control the initial query results and I can't seem to get it working - to be honest I'm a C coder not a VBA coder and am a bit of a n00b when it comes to Access and VB so I get a bit frustrated at the minute!
I have the following code that I have been testing linearly but eventually I want it to be recursive but thats a side issue as at the minute it does not want to close the form to move onto the next load
GBL_ClientID = "XXX"
On Error Resume Next
DoCmd.OpenReport "rptJobSheetBETA", acViewPreview
If Err = 2501 Then Err.Clear 'Else DoCmd.PrintOut
DoCmd.SelectObject acForm, "rptJobSheetBETA"
DoCmd.Close acForm, "rptJobSheetBETA"
DoEvents
GBL_ClientID = "YYY"
On Error Resume Next
DoCmd.OpenReport "rptJobSheetBETA", acViewPreview
If Err = 2501 Then Err.Clear 'Else DoCmd.PrintOut
DoCmd.SelectObject acForm, "rptJobSheetBETA"
DoCmd.Close acForm, "rptJobSheetBETA"
DoEvents
... etc etc
And so on. What currently happens is it loads the first job sheet and thats it - it should print the jobsheet then close the form, then reopen it with new data. I have multiple client IDs that the job sheets refer to but they all aren't necessarily done on a daily basis when the job sheets are created.
Could anyone shine some light on this problem at all? Am I making any sense?![Smile :) :)](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)
I have the following code that I have been testing linearly but eventually I want it to be recursive but thats a side issue as at the minute it does not want to close the form to move onto the next load
GBL_ClientID = "XXX"
On Error Resume Next
DoCmd.OpenReport "rptJobSheetBETA", acViewPreview
If Err = 2501 Then Err.Clear 'Else DoCmd.PrintOut
DoCmd.SelectObject acForm, "rptJobSheetBETA"
DoCmd.Close acForm, "rptJobSheetBETA"
DoEvents
GBL_ClientID = "YYY"
On Error Resume Next
DoCmd.OpenReport "rptJobSheetBETA", acViewPreview
If Err = 2501 Then Err.Clear 'Else DoCmd.PrintOut
DoCmd.SelectObject acForm, "rptJobSheetBETA"
DoCmd.Close acForm, "rptJobSheetBETA"
DoEvents
... etc etc
And so on. What currently happens is it loads the first job sheet and thats it - it should print the jobsheet then close the form, then reopen it with new data. I have multiple client IDs that the job sheets refer to but they all aren't necessarily done on a daily basis when the job sheets are created.
Could anyone shine some light on this problem at all? Am I making any sense?