transferring info from form to SQL query

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there any way to take data that I enter on a form in an ADP page and use
those values in an SQL Query? I don't have a clue as to what the syntax is
but I would guess I would be using a function in the query? I have tried
Forms!FormName!Item but I kept getting errors in the function designer.
 
Hi -

It sound to me like you are trying to "pull" data from a form directly into
a query. Is this correct? I don't think that is possible.

When I have to build a SQL string from data on a form, I do it entirely with
Visual Basic from within the Form itself. Then "push" the SQL string to it's
required function: e.g., as a recordsource property for a Form or Report, or
to make a new query (using QueryDef).

It is a little cumbersome, but it works. There are ways to make it a little
more efficient if each field for the query is a separate record on the form.
Then you can iterate through the recordset to include all the fields names
and where criteria in your query string. (I usually name the string "stSQL".)

Just remember, when putting in WHERE criteria into a string, to use & and to
bracket text with ' symbols and dates with # symbols.

Good luck,

Phil F.
Not an MVP
 
Back
Top