• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1731
  • Last Modified:

Data reports + pass a parameter

I would like to know how to add a variable to a datareport dataenvironment object to make a selection based on criteria...  I have tried:

SELECT * FROM TOPCARD WHERE (RSC = RSCTOPRINT)

In the SQL statement box but it does not work.
I have a global variable RSCTOPRINT defined in a variable and I am passing data to the variable befor the datareport is opened.  I just need help to figure out the syntax to put it in the SQL statement.
0
John Gates, CISSP
Asked:
John Gates, CISSP
  • 8
  • 3
  • 3
1 Solution
 
supunrCommented:
SQL = "SELECT * FROM TOPCARD WHERE (RSC = " & RSCTOPRINT & ")" ' if RSCTOPRINT is a number


SQL = "SELECT * FROM TOPCARD WHERE (RSC = """ & RSCTOPRINT & """)" ' if RSCTOPRINT is a string


good luck!
0
 
John Gates, CISSPSecurity ProfessionalAuthor Commented:
I am trying to put this in the dataenvironment object..  Should I be trying it somewhere else because it is not working...
0
 
John Gates, CISSPSecurity ProfessionalAuthor Commented:
I am trying to put this in the dataenvironment object..  Should I be trying it somewhere else because it is not working...
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
John Gates, CISSPSecurity ProfessionalAuthor Commented:
I am trying to put this in the dataenvironment object..  Should I be trying it somewhere else because it is not working...
0
 
supunrCommented:
   DataEnvironment1.Commands(0).CommandText = SQL
    DataEnvironment1.Commands(0).Execute
0
 
John Gates, CISSPSecurity ProfessionalAuthor Commented:
Where does that need to be entered?
0
 
supunrCommented:
whereever you change the RSCTOPRINT variable, because then you have to update the values in the query.  
0
 
John Gates, CISSPSecurity ProfessionalAuthor Commented:
All I want to do is have a form come up that asks which RSC I would like to print.  I would like to then open the datareport and only see the data from the selected RSC.  I cannot seem to figure this out.  I tried from the form and I did a MsgBOx to make sure that the call looked good ...  I cannot seem to get the data environment to allow me to pass a parameter.  If I try to leave the default value for a parameter blank then it give me the error no default value assigned to variable...  Well I have had enough for tonight...
0
 
tat83Commented:
Why don't u just pass the parameter to the data environment?
like this
ur sql SELECT * FROM TOPCARD WHERE RSC = ?
then when u click on a buuton
cmdreport_click()
call dataenvironment1.command1 (text1.text)
or
call dataenvironment1.command1 (RSCTOPRINT)
where text1 or rsctoprint is ur variable
hope it help
0
 
tat83Commented:
and of course u need to put
rptrepoprt.show
0
 
John Gates, CISSPSecurity ProfessionalAuthor Commented:
Why don't u just pass the parameter to the data environment?
like this
ur sql SELECT * FROM TOPCARD WHERE RSC = ?
then when u click on a buuton
cmdreport_click()
call dataenvironment1.command1 (text1.text)
or
call dataenvironment1.command1 (RSCTOPRINT)
where text1 or rsctoprint is ur variable
hope it help

What would the exact syntax be for this?
0
 
tat83Commented:
in the command properties of a dataenvironment
select sql statement
then type in this
SELECT * FROM Table WHERE field = ?
then click ok
On a command click event put this
call dataenvironment1.command1 (text1.text)
or
call dataenvironment1.command1 (RSCTOPRINT)
this will pass in text1.text to replace ? in the sql statement
And on report unload events put this
unload dataenvironment1
if not, the same report will be shown althought the parameter pass in is different
because it is still in the memory, so the same sql is execute with the same data
Hope i can help u
0
 
John Gates, CISSPSecurity ProfessionalAuthor Commented:
Thanks tat that did it =-)
0
 
John Gates, CISSPSecurity ProfessionalAuthor Commented:
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 8
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now