Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA to create report parameter forms

Status
Not open for further replies.

suzreid

Technical User
Joined
Sep 26, 2000
Messages
59
Location
GB
I have created a form in VBA that I want to use as a parameter form for creation of a report. Int he design of the report I have created the report with prompts. If I run the run the report, without the form, the prompts appear and the report data refreshes to give the correct data.

My problem is when I use the VBA form, I get an error saying the file is being modified by another user. The file isn't being used by anyone else but me.

On the Intialize event of the document, I have defaulted the values of the controls on the form and displayed the form. When I click the OK button on the form, to accept the parameters.

I think that it may have something to do with the report already being in memory when I try to refresh the report.

Any help with this will be greatly appreciated as I have another 10 reports to do, all basically following the same procedure.

Here is the code I am running.

On the report

Private Sub Document_Open()
Load rptRegistrarParameter
rptRegistrarParameter.Show
End Sub

On the form

Public BODataProv As BusObj.DataProvider
Public BORep As BusObj.Report
Public BO As BusObj.Application
Public blnCancel As Boolean
Public dteStartDate As Date
Public dteEndDate As Date
Public strPlace As String

Private Sub cmdOK_Click()

Set BO = CreateObject("BusinessObjects.Application")

dteStartDate = Me.DTPDateFrom
dteEndDate = Me.DTPDate2
strPlace = "aberdeen"

BO.Documents.Open ("t:\GPCT\product\pims universe\application\reports\died_in_GPCT1.rep")
BO.ActiveReport
BO.ActiveDocument.Variables("StartDate").Value = dteStartDate
BO.ActiveDocument.Variables("EndDate").Value = dteEndDate
BO.ActiveDocument.Variables("location").Value = strPlace
Unload Me
End Sub

Private Sub UserForm_Initialize()
Me.DTPDateFrom = Format(Now(), "dd-mm-yyyy")
Me.DTPDate2 = Format(Now(), "dd-mm-yyyy")
End Sub


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top