data environment

I have a data environment.  One of the commands is a SQL statment "Select * from labelshistory where (Status = 'PRINT') AND (EmployeeId = x)
I need to be able to pass the value for x.  Can someone tell me how to pass the paramater to the sql statement
LVL 3
jrspanoAsked:
Who is Participating?
 
Five_BsConnect With a Mentor Commented:
Have you tried enclosing the X value in square brackets making it a Named Parameter.  e.g. [X]

Check out "Specifying Parameter Marker Characters" in the MSDN Library
0
 
nguyennCommented:
If x is declared as integer,then you can try this:

"Select * from labelshistory where [Status]= '" & PRINT & "' and [EmployeeId] = " & x

0
 
GivenRandyCommented:
Set your SQL string like:

SQL = "Select * from labelshistory where (Status = 'PRINT') AND (EmployeeId = '" & Format$(x) & "')"

Then make your call.
0
Cloud Class® Course: CompTIA Healthcare IT Tech

This course will help prep you to earn the CompTIA Healthcare IT Technician certification showing that you have the knowledge and skills needed to succeed in installing, managing, and troubleshooting IT systems in medical and clinical settings.

 
jrspanoAuthor Commented:
It won't take the statement in the properties of the command in the data environment
0
 
GivenRandyCommented:
Did you try mine?  I put the x value in single quotes because we have had the same problem.
0
 
jrspanoAuthor Commented:
Yes i tried that one two.  In the data environment window i need a way to set the command's sql statement in code instead of entering it in the window.  then the above would work.  there may also be a way to enter the parameter in the window but the parameter tab is always greyed out and i can't get it to work.
0
 
jrspanoAuthor Commented:
this is getting closer.  How do you pass the value of x to the data environment?  It will let me run the program without any errors now but it returns an empty recordset because x is empty.  when x changes in the program i need a way to send it to the data environment and have it refresh.
0
 
jrspanoAuthor Commented:
I solved it by using an ado control on the form instead of a data environment.  this let me set the sql string in code.
0
 
jrspanoAuthor Commented:
five bs if you will give another comment i'll give you the points.  your answer got me the closest
0
 
jrspanoAuthor Commented:
Comment accepted as answer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.