View Full Version : query in a text box


eran185
05-20-2007, 09:32 PM
i have a form.
i made a query , and i can see the query (there are 2 fields , and i want to see one of them) only in a subform , but i want to see the query in a simple textbox.

how can i do this thing ?

neileg
05-21-2007, 01:28 AM
Us an aggregate function istead of the query. Dlookup(), DSum() or whatever is appropriate. This will return the single value to populate the text box.

eran185
05-21-2007, 08:57 PM
hey
its work almost perfect.
can u see the att file ?
when we go from the first deal to the second , the upper left text box still "200" (instead 30):(

boblarson
05-21-2007, 09:02 PM
Without looking at the database it sounds like you need to put your code in the On Current event too.

eran185
05-21-2007, 09:13 PM
i'm fresh with access
what u mean in "Current event" ?

boblarson
05-21-2007, 09:20 PM
Forms (and other objects) have events (BeforeUpdate, AfterUpdate, On Current, On Load, On Close, Open, etc.).

The Current event fires everytime the form moves between records.

You can get to them by opening the form in design mode and then clicking on the events tab on the properties dialog, then selecting the drop down [Event Procedure] and clicking on the elipsis (...) that appears.

eran185
05-21-2007, 09:25 PM
mmmm , i put in the code , but its the same ...
ohh...h...h..h.

EMP
05-21-2007, 11:52 PM
I can't read the text in your version of db. It's all Greek to me.

But it seems the DLookup in the top left text box needs to reference the numeric value in a text box in the subform. In English version, something like:-

=DLookUp("[Expr1]","queryName","[queryFieldName]=" & [Forms]![MainFormName]![SubformName].Form![textboxName])

^

eran185
05-22-2007, 12:58 AM
:confused:

EMP
05-22-2007, 11:03 AM
I pasted the various names from your db into the DLookup expression in the text box Control Source and was able to change the text box value from 190 to 30 when I moved to the second record.


I have attached two screenshot images. They display the DLookup expression and the number 30 in the text box result.

I have also attached my db. Because of version differences, the DLookup expression in the db is very unstable. It will change back to your original expression if I compress the db. Hopefully you can open and run it.

^

eran185
05-22-2007, 11:41 PM
hey

many thanks ...
;)