×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to pass group key value to a SQL statement

How to pass group key value to a SQL statement

How to pass group key value to a SQL statement

(OP)
Anyone knows how to pass getGroupKey() value to a SQL statement under the group. I tried this in Function ObtainSelectStatement() As String:

ObtainSelectStatement = "SELECT order from orders where order_date = '" & getGroupKey() & "'"

where getGroupKey() is date type. I got illegal use of variable error.

Any one can help me? Thanks!!!

RE: How to pass group key value to a SQL statement

I am not sure what you are trying to do. If I want to add a where clause to the Query I generally add a parameter of the appropriate datatype in you case probably string or date. Then when prompted for the parameter value I put in the condition I want met. So I am assuming that the ultimate query you want generated looks somehting like SELECT order from orders where order_date = '2002-08-16'. I also think with your approach there is a scoping issue, as well as getGroupKey() will probably not return a specific date so the query will be incorrect.

RE: How to pass group key value to a SQL statement

(OP)
Andrew, using parameter is not a solution. There is a master SQL statement that drives a number of grouped reports, say reports by months, such as Jan, Feb and so on. So month here is the group key. Within one month group I added a section with its own data source. The "where" clause for this data source is associated with the group key information. For example the where clause should be like: "where orderDate ='" & groupKey & "'". The groupKey is a variable that I need to pass the group key value to it. In text control, I can use getGroupKey() function to get the key value, but I don't know how to get the value in my SQl statement.

Thanks for your help.

Jeff    

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close