Hail,
When I run the following code to modify design of a report I get an automation error if I run it more than once (first time works!!!)
Dim Obj As Object
Dim Rep As Report
Set Obj = CreateObject("access.application"
Obj.Visible = False
Obj.OpenCurrentDatabase DBPath & "InterfaceRapports.mdb"
Obj.DoCmd.OpenReport QueryName, acViewDesign
Set Rep = Obj.Reports(QueryName)
'Rep!Start.ControlSource = "=Format(DateAdd('h', " & DST & ", [gmt_strt]), 'hh:nn')"
'Rep!lblTitle.Caption = ReportTitle
Obj.DoCmd.Close acReport, QueryName, acSaveYes
Obj.DoCmd.OpenReport QueryName, acViewNormal
Obj.CloseCurrentDatabase
Obj.Quit
Set Obj = Nothing
Set Rep = Nothing
In debug mode, the problem for my automation error seems to be for
Set Rep = Reports(queryname)
The first time I run it in debug mode, when I move my mouse cursor over "Reports" is gives me the following:
Object variable or with block variable not set
But it does accept anyway and continues on
The second time I run the code, instead of the above message I get Automation Error!
When I run the following code to modify design of a report I get an automation error if I run it more than once (first time works!!!)
Dim Obj As Object
Dim Rep As Report
Set Obj = CreateObject("access.application"
Obj.Visible = False
Obj.OpenCurrentDatabase DBPath & "InterfaceRapports.mdb"
Obj.DoCmd.OpenReport QueryName, acViewDesign
Set Rep = Obj.Reports(QueryName)
'Rep!Start.ControlSource = "=Format(DateAdd('h', " & DST & ", [gmt_strt]), 'hh:nn')"
'Rep!lblTitle.Caption = ReportTitle
Obj.DoCmd.Close acReport, QueryName, acSaveYes
Obj.DoCmd.OpenReport QueryName, acViewNormal
Obj.CloseCurrentDatabase
Obj.Quit
Set Obj = Nothing
Set Rep = Nothing
In debug mode, the problem for my automation error seems to be for
Set Rep = Reports(queryname)
The first time I run it in debug mode, when I move my mouse cursor over "Reports" is gives me the following:
Object variable or with block variable not set
But it does accept anyway and continues on
The second time I run the code, instead of the above message I get Automation Error!