RE: Expression Builder basic question on syntax / Or / how to incorpor



Given that Access is a File Server application rather than a Client Server
application, it is always best to avoid unnecessary hits on the database.
They slow the application and increase network load.

You can easily get a sum of two text boxes like you want. Just do the math
using the two controls you want. Use only the control name without the Me.
Also, it is a good idea when doing this to wrap your values in the Nz
function. Any calculations that contain a Null value will result in Null.

Make this the Control Source of the control you want the sum in:

=Nz(txtQuantity,0) * Nz(txtPrice,0)
--
Dave Hargis, Microsoft Access MVP


"raylopez99" wrote:

I would like to add a textbox on my control that is not linked to a
database (like the other textboxes are, which are linked to fields in
the database), that takes the sum of all the textboxes in the form.
How to do this using "Expression Builder"? (Or otherwise?). I'm
having problems with the syntax, since I keep getting the "#Name?"
runtime error on the textbox. **See below, I also would like to know
using Visual Basic if possible.

Concrete example:

Field #1 (linked to a database): Quantity
Field #2 (" ") : Price
Textbox #3 (this I want to compute from fields #1 and #2, in a textbox
control on my Access 2003 form): = Quantity * Price

Any way appreciated. What I did was run a SQL query ("SELECT
Sum(Subform1.Quantity*Subform1.PricePerShare) AS SumTotal
FROM AccountStocks INNER JOIN Subform1 ON
AccountStocks.AccountStockID=StkTransactions.Account_StockID
GROUP BY AccountStocks.AccountStockID;) <--two tables, linked by a
key, the query being called "Query1" having alias SumTotal

This SQL query works (when run seperately), giving a sum for each
record, and just for learning purposes I'd like to incorporate this
query using the "Expression builder" for the textbox #3.

However, I'll take any easy way of doing the above.

Thank you

RL

PS--I tried various things, and nothing seems to work. For example I
took the name of the Textbox, Textbox3, and set it equal to ("Query1!
SumTotal"). Then....(various other things tried deleted)...

UPDATE: Ok, surfing the net before I hit enter (sorry I'm on a dialup
modem right now, so surfing is painful) I see that a lot of people
don't use the Expression Builder, instead they like to use Visual
Basic in an [event procedure] That's fine, I'd like to know how to
incorporate the SQL query above...do I use it in an event procedure
(and which one? There are so many, in the past for other stuff I use
"OnGotFocus" but I doubt that's the best for this query since the user
would have to click on the box to get an answer).

Also, do I set the SQL query as a "Control Source" under the
Properties tab of the textbox #3? (Just tried that, using an equal
sign in front, and without it, and it doesn't work, still gives the
#Name? scope problem again).

Any ideas? This question is very basic so please don't think too
hard...(I think).

RL

.



Relevant Pages

  • Re: Data Controls Suck: No Vertical Layout?
    ... FYI -- I am now discovering the joys of the 3.5 ListView control which apparently was specifically developed to support complete control of data presentation and NURD processes. ... I want and need two columns, the left is a LinkButton with text property that has the name of the database field and the right the TextBox that contains the data in from the database that CRUD can then function with. ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: datagrid question
    ... Than first a question, what is a control in your opinion, this are complete ... Your application will be very much dependable what database you use and what ... Make a textbox ... Bind that dataset to your datagrid using the datasource property ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Before Update problem
    ... Value does not require the control to have the focus. ... > BeforeUpdate event's code is running, and the textbox is trying to change ... The database has been updated through the years from ... >> Dim x As String, y As String, z As Integer ...
    (microsoft.public.access.formscoding)
  • Re: Expression Builder basic question on syntax / Or / how to incorporate a SQL query into a textbox
    ... the database), that takes the sum of all the textboxes in the form. ... runtime error on the textbox. ... This SQL query works, ...
    (microsoft.public.access.formscoding)
  • On Current Event Property woes
    ... database, we'll call that database 'B', and the table is ... called 'Register Protocol'. ... CCI_Number field in 'A' is a SQL query: ... enter a null value into the CCI_Number's control. ...
    (microsoft.public.access.formscoding)