ADODC recordsource SQL

From: cellarstudio (anonymous_at_discussions.microsoft.com)
Date: 02/23/04


Date: Sun, 22 Feb 2004 16:16:07 -0800

I have an ADODC control on a form with a data grid. I have set the connection to the DNS. When I set the record source to my access query, all the records show up in the grid fine. But what I would like to do is set the record source to the following SQL:

SELECT * FROM VacationQuery WHERE UserID = '" & g_strUser & "'

where g_strUser is a global variable that contains the userID of the person that is currently logged into the program.
I have a label at the top of the form that displays the contents of g_strUser (on form Load), just to make sure variable works.
When I use the SQL, the grid is empty, and is should be showing the records of the user logged in.

My first question is can you even use a variable in the sql of the recordsource for an ADODC?
Next questions..if I were to write code for the connection and sql (instead of using the ADODC tool and setting the properties), where does that code go? on form load?