Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2004
    Posts
    6

    Question Unanswered: running the same query multiple times

    I was wondering is it possible to run the same query multiple times on one table, using MS Access. Maybe not the same exact query. The only way that the query changes is the terms in which i am searching for. If someone could help me with this, I would greatly appreciate it.

  2. #2
    Join Date
    Feb 2004
    Posts
    533
    What you are thinking of is using variable values in a query. This is a frequent practice in Access and there are a few ways to design the functionality. Typically you will have a query that returns data and a form which provides the user interface to interact with the query. The results could be displayed directly from the query or even better on a another or the same form

    Here's an example of a function which could be used as the criteria of a query. It refers to a textbox on a form the form would have to be active when the query is run.

    Like ("*" & [Forms]![frmLookUp]![txtInput] & "*")

    Another way would be to run a query dynamically or create a query string in a procedure that can be applied to the Recordsource property of the form or returned in a recordset. Part of the code might look like this...

    strCriteria = Me![txtInput]

    strQry = "SELECT ITEM.* " & _
    " FROM tblITEM " & _
    " WHERE (((ITEM.ID)='" & strCriteria & "'))"
    ~

    Bill

Posting Permissions

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