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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

BO: parameter in Querz

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Dear All,

I would like to filter the data in report giving the value at the time of running the report. For this purpose, i have designed a VBA form and will call this for on BeforeRefresh event and user can enter value for the parameter. Now my question is how to use the paramete in the querz and assign value to it at runtime.
Many thanks in advance,
visu
 
The below sample with little customization would help you

Dim mydoc As Document
Dim myrpt As Report
Dim mydp As DataProvider
Dim mycond As Condition
dim concount as Integer
Set mydoc = Application.Documents.Open("Name of the doc")
Set mydp = mydoc.DataProviders(1)
condcount = mydp.Queries(1).Conditions.Count
MsgBox condcount
MsgBox Now
mydp.Load
For i = 1 To condcount
mydp.Queries(1).Conditions.Remove (1)
Next i
condformatcount = 0
Set mycond = mydp.Queries(1).Conditions.Add("Class name", "object name", "Equal to (or any other operator)", " value ")

condformatcount = 1


Set mycond = mydp.Queries(1).Conditions.Add("Class name", "object name", "Equal to (or any other operator)", " value ")
condformatcount = 1

CondFormat = "("
For i = 1 To condformatcount
If i <> condformatcount Then
CondFormat = CondFormat & &quot;#&quot; & i & &quot; AND &quot;
Else
CondFormat = CondFormat & &quot;#&quot; & i & &quot;)&quot;
End If
Next i
mydp.Queries.Item(1).Conditions.Format = CondFormat
mydp.Unload
DoEvents
mydoc.Refresh

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top