reference to a form's field, in query

M

Mark

Anyone have an idea why the following is not working for me? I have an open form, which launches a process that runs queries. In one of the queries, I want to populate a field with the value from a text box on the form. (I have an end date field on form that user selects, want to list that same selected date in an 'as of date' column in query.) The query allows the syntax I'm using, but always returns an empty value. (And yes, the form is still open when query runs.

Open form and field on it: [Forms]![iFrmRptSel]![txtEnd

SQL of query: "SELECT "dB" AS Source, [Forms]![iFrmRptSel]![txtEnd] AS [As of], tblName.QUANTITY_ORDERED*tblName.LIST_PRICE_PER_UNIT*1.12 AS [Total Amount
FROM tblName;

Why does this not return the date value that is present in the form's field? Just returns empty cells, for the 'As of' column
 
E

Elwin

You should delimit the parameter so the query knows what
data type to assign to it.

"SELECT 'dB' AS Source, '#' & [Forms]![iFrmRptSel]!
[txtEnd] & '#' AS [As of], "...

Is 'txtEnd' a bound control (does it have a control
source)? if so, you'll need to either save the record
prior to running the query, or reference the
control's 'Text' property

[Forms]![iFrmRptSel]![txtEnd].[Text]

good luck!
-----Original Message-----
Anyone have an idea why the following is not working for
me? I have an open form, which launches a process that
runs queries. In one of the queries, I want to populate a
field with the value from a text box on the form. (I have
an end date field on form that user selects, want to list
that same selected date in an 'as of date' column in
query.) The query allows the syntax I'm using, but always
returns an empty value. (And yes, the form is still open
when query runs.)
Open form and field on it: [Forms]![iFrmRptSel]![txtEnd]

SQL of query: "SELECT "dB" AS Source, [Forms]!
[iFrmRptSel]![txtEnd] AS [As of],
tblName.QUANTITY_ORDERED*tblName.LIST_PRICE_PER_UNIT*1.12
AS [Total Amount]
FROM tblName;"

Why does this not return the date value that is present
in the form's field? Just returns empty cells, for
the 'As of' column.
 
M

Mark

THANKS! You da ma

----- Elwin wrote: ----

You should delimit the parameter so the query knows what
data type to assign to it

"SELECT 'dB' AS Source, '#' & [Forms]![iFrmRptSel]
[txtEnd] & '#' AS [As of], "..

Is 'txtEnd' a bound control (does it have a control
source)? if so, you'll need to either save the record
prior to running the query, or reference the
control's 'Text' propert

[Forms]![iFrmRptSel]![txtEnd].[Text

good luck
-----Original Message----
Anyone have an idea why the following is not working for
me? I have an open form, which launches a process that
runs queries. In one of the queries, I want to populate a
field with the value from a text box on the form. (I have
an end date field on form that user selects, want to list
that same selected date in an 'as of date' column in
query.) The query allows the syntax I'm using, but always
returns an empty value. (And yes, the form is still open
when query runs.
Open form and field on it: [Forms]![iFrmRptSel]![txtEnd
SQL of query: "SELECT "dB" AS Source, [Forms]
[iFrmRptSel]![txtEnd] AS [As of],
tblName.QUANTITY_ORDERED*tblName.LIST_PRICE_PER_UNIT*1.12
AS [Total Amount
FROM tblName;
in the form's field? Just returns empty cells, for
the 'As of' column
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top