Returning Value from Query to a Textbox in Form

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

Guest

after running a query from a form, by using a command button, is it possible
to return the result of the query to a textbox in the same form?

eg....in the form i need to enter the Qty then run a query to calculate the
TotalCosts. I want to show the TotalCost in a Textbox in the form.


thanks!

Dave
 
no.....it's not that simple, as the cost price is not a fixed rate. The user
has a table to enter costs for different qty ranges.

eg Qty 1 to 10 - Cost 5.00
Qty 11 to 20 - Cost 4.50
Qty 21 to 30 - Cost 4.00
Qty 31 to 50 - Cost 3.50

etc

Ofer said:
Why do you need to run a query for that?

If you have a two fields in the form, Qty and Price, then create another
field to sum the two fields, in the control source of the third field write

=[Qty] * [Price]

Or, I might be missing something.
--
\\// Live Long and Prosper \\//
BS"D


DaveAlfa said:
after running a query from a form, by using a command button, is it possible
to return the result of the query to a textbox in the same form?

eg....in the form i need to enter the Qty then run a query to calculate the
TotalCosts. I want to show the TotalCost in a Textbox in the form.


thanks!

Dave
 
Why do you need to run a query for that?

If you have a two fields in the form, Qty and Price, then create another
field to sum the two fields, in the control source of the third field write

=[Qty] * [Price]

Or, I might be missing something.
 
Try and create a field on the form to display the cost, if the table has the
qty from and the qty to in two different fields, then you can try this on the
control source

=Dlookup("[Cost]","[Table Name]","[Qty From] >= " & [Qty field Name in the
form] & " And [Qty To] <= " & [Qty field Name in the form] )

That will display the cost for the qty entered.
=================================
To dispay the Total you can use
=[Qty field Name in the form] * Nz(Dlookup("[Cost]","[Table Name]","[Qty
From] >= " & [Qty field Name in the form] & " And [Qty To] <= " & [Qty field
Name in the form] ),0)

--
\\// Live Long and Prosper \\//
BS"D


DaveAlfa said:
no.....it's not that simple, as the cost price is not a fixed rate. The user
has a table to enter costs for different qty ranges.

eg Qty 1 to 10 - Cost 5.00
Qty 11 to 20 - Cost 4.50
Qty 21 to 30 - Cost 4.00
Qty 31 to 50 - Cost 3.50

etc

Ofer said:
Why do you need to run a query for that?

If you have a two fields in the form, Qty and Price, then create another
field to sum the two fields, in the control source of the third field write

=[Qty] * [Price]

Or, I might be missing something.
--
\\// Live Long and Prosper \\//
BS"D


DaveAlfa said:
after running a query from a form, by using a command button, is it possible
to return the result of the query to a textbox in the same form?

eg....in the form i need to enter the Qty then run a query to calculate the
TotalCosts. I want to show the TotalCost in a Textbox in the form.


thanks!

Dave
 
thanks!

worked perfectly fine...just a small amendment...had to change the '<' with
'>' & vice-versa.

what does the 'nz' do in 'Nz(DLookUp.......' ?

thanks

Dave

Ofer said:
Try and create a field on the form to display the cost, if the table has the
qty from and the qty to in two different fields, then you can try this on the
control source

=Dlookup("[Cost]","[Table Name]","[Qty From] >= " & [Qty field Name in the
form] & " And [Qty To] <= " & [Qty field Name in the form] )

That will display the cost for the qty entered.
=================================
To dispay the Total you can use
=[Qty field Name in the form] * Nz(Dlookup("[Cost]","[Table Name]","[Qty
From] >= " & [Qty field Name in the form] & " And [Qty To] <= " & [Qty field
Name in the form] ),0)

--
\\// Live Long and Prosper \\//
BS"D


DaveAlfa said:
no.....it's not that simple, as the cost price is not a fixed rate. The user
has a table to enter costs for different qty ranges.

eg Qty 1 to 10 - Cost 5.00
Qty 11 to 20 - Cost 4.50
Qty 21 to 30 - Cost 4.00
Qty 31 to 50 - Cost 3.50

etc

Ofer said:
Why do you need to run a query for that?

If you have a two fields in the form, Qty and Price, then create another
field to sum the two fields, in the control source of the third field write

=[Qty] * [Price]

Or, I might be missing something.
--
\\// Live Long and Prosper \\//
BS"D


:

after running a query from a form, by using a command button, is it possible
to return the result of the query to a textbox in the same form?

eg....in the form i need to enter the Qty then run a query to calculate the
TotalCosts. I want to show the TotalCost in a Textbox in the form.


thanks!

Dave
 
thanks very much!!!


Dave



Ofer said:
The Nz function replace Null with any value specified

Nz([FieldName],0)
So incase the FieldName return Null the Nz will return 0

Nz([FieldName],1)
Or 1

So if the Dlookup wont return a match, the nz will replace the null with 0.

--
\\// Live Long and Prosper \\//
BS"D


DaveAlfa said:
thanks!

worked perfectly fine...just a small amendment...had to change the '<' with
'>' & vice-versa.

what does the 'nz' do in 'Nz(DLookUp.......' ?

thanks

Dave

Ofer said:
Try and create a field on the form to display the cost, if the table has the
qty from and the qty to in two different fields, then you can try this on the
control source

=Dlookup("[Cost]","[Table Name]","[Qty From] >= " & [Qty field Name in the
form] & " And [Qty To] <= " & [Qty field Name in the form] )

That will display the cost for the qty entered.
=================================
To dispay the Total you can use
=[Qty field Name in the form] * Nz(Dlookup("[Cost]","[Table Name]","[Qty
From] >= " & [Qty field Name in the form] & " And [Qty To] <= " & [Qty field
Name in the form] ),0)

--
\\// Live Long and Prosper \\//
BS"D


:

no.....it's not that simple, as the cost price is not a fixed rate. The user
has a table to enter costs for different qty ranges.

eg Qty 1 to 10 - Cost 5.00
Qty 11 to 20 - Cost 4.50
Qty 21 to 30 - Cost 4.00
Qty 31 to 50 - Cost 3.50

etc

:

Why do you need to run a query for that?

If you have a two fields in the form, Qty and Price, then create another
field to sum the two fields, in the control source of the third field write

=[Qty] * [Price]

Or, I might be missing something.
--
\\// Live Long and Prosper \\//
BS"D


:

after running a query from a form, by using a command button, is it possible
to return the result of the query to a textbox in the same form?

eg....in the form i need to enter the Qty then run a query to calculate the
TotalCosts. I want to show the TotalCost in a Textbox in the form.


thanks!

Dave
 
The Nz function replace Null with any value specified

Nz([FieldName],0)
So incase the FieldName return Null the Nz will return 0

Nz([FieldName],1)
Or 1

So if the Dlookup wont return a match, the nz will replace the null with 0.

--
\\// Live Long and Prosper \\//
BS"D


DaveAlfa said:
thanks!

worked perfectly fine...just a small amendment...had to change the '<' with
'>' & vice-versa.

what does the 'nz' do in 'Nz(DLookUp.......' ?

thanks

Dave

Ofer said:
Try and create a field on the form to display the cost, if the table has the
qty from and the qty to in two different fields, then you can try this on the
control source

=Dlookup("[Cost]","[Table Name]","[Qty From] >= " & [Qty field Name in the
form] & " And [Qty To] <= " & [Qty field Name in the form] )

That will display the cost for the qty entered.
=================================
To dispay the Total you can use
=[Qty field Name in the form] * Nz(Dlookup("[Cost]","[Table Name]","[Qty
From] >= " & [Qty field Name in the form] & " And [Qty To] <= " & [Qty field
Name in the form] ),0)

--
\\// Live Long and Prosper \\//
BS"D


DaveAlfa said:
no.....it's not that simple, as the cost price is not a fixed rate. The user
has a table to enter costs for different qty ranges.

eg Qty 1 to 10 - Cost 5.00
Qty 11 to 20 - Cost 4.50
Qty 21 to 30 - Cost 4.00
Qty 31 to 50 - Cost 3.50

etc

:

Why do you need to run a query for that?

If you have a two fields in the form, Qty and Price, then create another
field to sum the two fields, in the control source of the third field write

=[Qty] * [Price]

Or, I might be missing something.
--
\\// Live Long and Prosper \\//
BS"D


:

after running a query from a form, by using a command button, is it possible
to return the result of the query to a textbox in the same form?

eg....in the form i need to enter the Qty then run a query to calculate the
TotalCosts. I want to show the TotalCost in a Textbox in the form.


thanks!

Dave
 
Back
Top