Passing a number to an Access Query

Results 1 to 2 of 2

Thread: Passing a number to an Access Query

  1. #1
    Join Date
    Dec 1969

    Default Passing a number to an Access Query

    I remember seeing an article about this some time ago. Instead of creating long queries and passing them through ASP when working with MS Access, one can of course create the Query in Access, and then do a SELECT based on that query. That all works fine for me, and I know how to do that.<BR><BR>However, how do you pass a variable into that query which is already prebuild? This is an example of a query in Access:<BR><BR>SELECT articles.title, articles.description<BR>FROM articles<BR>WHERE articles.ID=1;<BR><BR>I need to be able to pass that number in through ASP, instead of doing it the traditional way:<BR><BR>numID = 1<BR>strSQL = "SELECT articles.title, articles.description " _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& "FROM articles " _<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& "WHERE articles.ID=" & numID<BR><BR>Any ideas???

  2. #2
    Join Date
    Dec 1969

    Default RE: Passing a number to an Access Query

    In your query, it would be:<BR>SELECT articles.title, articles.description<BR>FROM articles<BR>WHERE articles.ID=[ArticleID]<BR><BR>In your ASP page it would be:<BR>strSQL = "qryGetArticle " & numID<BR><BR>Give that a whirl...<BR><BR>-Doug

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts