Re: Global variables are slowing down the query
- From: "Allen Browne" <AllenBrowne@xxxxxxxxxxxxxx>
- Date: Tue, 9 Aug 2005 20:51:26 +0800
In the query design grid, typically in the Criteria row, you can refer to a
text box on an open form like this:
[Forms].[Form1].[Text0]
This becomes part of the SQL statement like this:
WHERE Table1.Field1 = [Forms].[Form1].[Text0]
Ideally you want to declare this as a parameter to the query, to ensure the
data type is interpreted correctly.
If you are comfortable with writing SQL, you could create the SQL string
dynamically, concatenating the value from the form or variable directly into
the SQL string, e.g.:
Dim strSql As String
strSql = "SELECT Table1.* FROM Table1 WHERE Table1.Field1 = " &
MyVariable & ";"
Then you can assign this to the RecordSource of a form:
Me.RecordSource = strSql
or to a saved query:
dbEngine(0)(0).QueryDefs("Query1").SQL = strSql
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Jean" <jeanjanssens@xxxxxxxxxxx> wrote in message
news:1123590128.375309.31220@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Yes, I guess I could use that method.
>
> Originally, I have the user select the string in a ComboBox, and the
> date(s) from the second column in a ListBox. I have to iterate through
> the date ListBox, as it is in Extended mode and a user can select
> multiple entries.
>
> But the point is: How do I reference the value of a form's control -
> directly in SQL? Or does one do it in the QBE grid? I have never seen
> this done so I would appreciate it if you could tell me.
>
> Thanks for your support so far!
.
- References:
- Global variables are slowing down the query
- From: Jean
- Re: Global variables are slowing down the query
- From: Allen Browne
- Re: Global variables are slowing down the query
- From: Jean
- Global variables are slowing down the query
- Prev by Date: Set Toolbar Combobox items when Toolbar is called?
- Next by Date: Re: Access 2k3 Forgetting my code? :(
- Previous by thread: Re: Global variables are slowing down the query
- Next by thread: Re: Global variables are slowing down the query
- Index(es):
Relevant Pages
|