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!

Data Report Query

Status
Not open for further replies.

phzero

Programmer
Feb 14, 2002
86
ZA
Hi All,

Does anyone know how I can pass a SQL statement as a parameter into the Data Report Designer from my source code. I have seen the Parameters Tab on the Properties Dialog Box but it is disabled
 
Are you going via a DataEnvironment or setting your Datareport DataSource in code?

If you're doing it in code, then use the parameters to change your DataSource, then re-assign.
dr1.DataSource = myNewRst

If you're using a DataEnvironment, then select the command that you want to use, click the SQL statement checkbox on the properties|General tab and type your complete SQL statement in there, e.g.:

SELECT Add1, Add2, Add3, ClientName, sold FROM tblClients WHERE (ClientName LIKE input1)

Now when you click on the Parameters tab, you'll find Input1 on the list. You can set it's name (as seen outside) and it's properties as required.

Then in code call it as e.g.:

strParam1 = "%" & Text3.Text & "%"

With de1
If .Connection2.State <> 0 Then .Connection2.Close
DoEvents
.Connection2.Open
.Command1 (strParam1)
End With
dr1.Show

In the example text3 contains the parameter, de1 is the name of the DataEnvironment, dr1 is the name of the DataReport and I'm using Command1 in Connection2 of the DatEnvironment



________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Hi johnwm,

Thank you so much for the reply, but it does not work for me. I am using a DataEnv. My command is called cmdMembers with this SQL statement:
select * from members where (memid = input1), but when I go to the Parameters Tab, input1 does not show up there. Am I missing something? Please help. Thanks in advance.
 
I'm sorry but I can't duplicate your result. Any change to the parameters in the SQL statement on the General tab are immediately reflected on the Parameters tab.

Try using the SQL builder button, otherwise it sounds like a re-install of VB!

Good Luck


________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
johnwm,

Thanks for the feedback. Could you tell me, why do you use &quot;input1&quot; in the SQL statement. Is it a reserved word in this instance?
 
Hi Johnwm,

After browsing the MSDN site extensively, I have found my answer. Actually, instead of putting &quot;input1&quot; in the query, I replaced it with a question mark &quot;?&quot; upon which param1 showed up on my Parameters Tab. Thanks for all the help though, I really do appreciate it. Keep well. Here is the URL: Search for &quot;Parameterized DataReport&quot;. Article number is: Microsoft Knowledge Base Article - 244779
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top