samj
asked on
requery a report
access 2000 report
If IsLoaded("rptTransGroups") = True Then
DoCmd.Close acReport, "rptTransGroups"
so that I can reopen the report with new criteria
Function IsLoaded(ByVal strObjName As String) As Integer
' Returns True if the specified form is loaded.
Const conDesignView = 0
Const conObjStateClosed = 0
IsLoaded = False
If SysCmd(acSysCmdGetObjectSt ate, acForm, strObjName) <> conObjStateClosed Then
If Forms(strObjName).CurrentV iew <> conDesignView Then
IsLoaded = True
End If
End If
If SysCmd(acSysCmdGetObjectSt ate, acReport, strObjName) <> conObjStateClosed Then
If Reports(strObjName).Curren tView <> conDesignView Then <<<<<<<<<<<<<<<<<<
IsLoaded = True
End If
End If
End Function
The line in <<<<<<<<<< above is giving me
Run time error 2465
Application defined or object defined error.
The report is open already but I need to roguery it since its data are based on a query. So how do I do that, is there a report roguery or close and reopen? And how to fix this?
Thanks
If IsLoaded("rptTransGroups")
DoCmd.Close acReport, "rptTransGroups"
so that I can reopen the report with new criteria
Function IsLoaded(ByVal strObjName As String) As Integer
' Returns True if the specified form is loaded.
Const conDesignView = 0
Const conObjStateClosed = 0
IsLoaded = False
If SysCmd(acSysCmdGetObjectSt
If Forms(strObjName).CurrentV
IsLoaded = True
End If
End If
If SysCmd(acSysCmdGetObjectSt
If Reports(strObjName).Curren
IsLoaded = True
End If
End If
End Function
The line in <<<<<<<<<< above is giving me
Run time error 2465
Application defined or object defined error.
The report is open already but I need to roguery it since its data are based on a query. So how do I do that, is there a report roguery or close and reopen? And how to fix this?
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi Jeff. I don't know much about Access 2007... is there an equivalent RunCommand constant, too?
(°v°)
(°v°)
ASKER
I am getting Run time error 3078, at the line is marked below.
Const RPT_NAME = "rptTransGroups"
If SysCmd(acSysCmdGetObjectSt ate, acReport, RPT_NAME) Then
DoCmd.Close acReport, RPT_NAME
DoCmd.OpenReport RPT_NAME, acViewPreview, , crit
Else
DoCmd.OpenReport RPT_NAME, acViewPreview, , crit <<<<<<<<<<<<<<<<<<<<<<<
End If
?crit
[TrnsDate] >=#02-01-2002# AND [TrnsDate] <= #02-28-2002#
Const RPT_NAME = "rptTransGroups"
If SysCmd(acSysCmdGetObjectSt
DoCmd.Close acReport, RPT_NAME
DoCmd.OpenReport RPT_NAME, acViewPreview, , crit
Else
DoCmd.OpenReport RPT_NAME, acViewPreview, , crit <<<<<<<<<<<<<<<<<<<<<<<
End If
?crit
[TrnsDate] >=#02-01-2002# AND [TrnsDate] <= #02-28-2002#
Error 3078 is "The Microsoft Jet database engine cannot find the input table or query"... This would mean your report doesn't work at all at the moment... Does it? Can you open it from the interface? Does it work without the criteria (which is perfectly correct, assuming there is a field TrnsDate in the report's record source)?
(°v°)
(°v°)
harfang,
" is there an equivalent RunCommand constant, too?"
I could not find any.
I tried these:
(which may or may not be the same in Access 2003 and lower)
'DoCmd.RunCommand acCmdRefresh
'DoCmd.RunCommand acCmdRefreshData
'DoCmd.RunCommand acCmdRefreshPage
'DoCmd.RunCommand acCmdDiscardChangesAndRefr esh
... and none refreshed the report, the only thing that dynamically refreshed the report was clicking the "Refresh All" button from the Records "chunk" in Accecess 2007.
Jeff
" is there an equivalent RunCommand constant, too?"
I could not find any.
I tried these:
(which may or may not be the same in Access 2003 and lower)
'DoCmd.RunCommand acCmdRefresh
'DoCmd.RunCommand acCmdRefreshData
'DoCmd.RunCommand acCmdRefreshPage
'DoCmd.RunCommand acCmdDiscardChangesAndRefr
... and none refreshed the report, the only thing that dynamically refreshed the report was clicking the "Refresh All" button from the Records "chunk" in Accecess 2007.
Jeff
Jeff,
Perhaps Access 2007 does it like we did here: close and reopen the report? On the other hand, there are so many acCmd constants, it's hard to get an overview. I sometimes copy-paste the entire list of constants from help to a text editor, just so I can search for key words among them... I should really take the time to study that version a bit...
samj,
I take it you found what was wrong with the report. Kudos and success with your project!
(°v°)
Perhaps Access 2007 does it like we did here: close and reopen the report? On the other hand, there are so many acCmd constants, it's hard to get an overview. I sometimes copy-paste the entire list of constants from help to a text editor, just so I can search for key words among them... I should really take the time to study that version a bit...
samj,
I take it you found what was wrong with the report. Kudos and success with your project!
(°v°)
ASKER
Thanks harfang. all is well.
If the Report is based on a query, then every time you open it, it refreshes and displays the most current data.
So unless you are leaving the report open on the screen for "Hours" at a time, I don't see the need to refresh it.
That being said, ...In Access 2007 there is a "Refreh All" button that will refresh (requery) the Report on demand.
In Access 2003 and earlier, you may just have to close then re-open the report.
JeffCoachman