query in a text box

eran185

Registered User.
Local time
Today, 15:09
Joined
May 11, 2007
Messages
55
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 ?
 
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.
 
ohh....

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):(
 

Attachments

Without looking at the database it sounds like you need to put your code in the On Current event too.
 
i'm fresh with access
what u mean in "Current event" ?
 
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.
 
mmmm , i put in the code , but its the same ...
ohh...h...h..h.
 
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])

^
 
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.

^
 

Attachments

  • DLookup expression in text box Control Source.jpg
    DLookup expression in text box Control Source.jpg
    53.2 KB · Views: 158
  • Text box changes to 30 for second record.jpg
    Text box changes to 30 for second record.jpg
    41.5 KB · Views: 141
  • abc db.zip
    abc db.zip
    48.3 KB · Views: 139

Users who are viewing this thread

Back
Top Bottom