?
Solved

Data reports + pass a parameter

Posted on 2003-03-27
14
Medium Priority
?
1,729 Views
Last Modified: 2012-05-04
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
Comment
Question by:John Gates, CISSP
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 3
  • 3
14 Comments
 
LVL 11

Expert Comment

by:supunr
ID: 8222675
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
 
LVL 18

Author Comment

by:John Gates, CISSP
ID: 8222716
I am trying to put this in the dataenvironment object..  Should I be trying it somewhere else because it is not working...
0
 
LVL 18

Author Comment

by:John Gates, CISSP
ID: 8222748
I am trying to put this in the dataenvironment object..  Should I be trying it somewhere else because it is not working...
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 18

Author Comment

by:John Gates, CISSP
ID: 8222775
I am trying to put this in the dataenvironment object..  Should I be trying it somewhere else because it is not working...
0
 
LVL 11

Expert Comment

by:supunr
ID: 8222788
   DataEnvironment1.Commands(0).CommandText = SQL
    DataEnvironment1.Commands(0).Execute
0
 
LVL 18

Author Comment

by:John Gates, CISSP
ID: 8222815
Where does that need to be entered?
0
 
LVL 11

Expert Comment

by:supunr
ID: 8222873
whereever you change the RSCTOPRINT variable, because then you have to update the values in the query.  
0
 
LVL 18

Author Comment

by:John Gates, CISSP
ID: 8222931
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
 

Expert Comment

by:tat83
ID: 8223178
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
 

Expert Comment

by:tat83
ID: 8223183
and of course u need to put
rptrepoprt.show
0
 
LVL 18

Author Comment

by:John Gates, CISSP
ID: 8228131
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
 

Accepted Solution

by:
tat83 earned 240 total points
ID: 8230108
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
 
LVL 18

Author Comment

by:John Gates, CISSP
ID: 8232296
Thanks tat that did it =-)
0
 
LVL 18

Author Comment

by:John Gates, CISSP
ID: 8232392
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month11 days, left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question