Query Results in Text Box


J

J. Trucking

Hello,

I have an existing form with employee data. I have just finished
building a query that is a summation of the hours that an employee has
worked at the company. It is a totals query so it always returns one
answer. What I would like to do is have the results of the query
appear in the Employee Form (frmEmployees) that I have created. The
query and form share the common field EmployeeID. Therefore on the
query, I said the criteria for the EmployeeID was to be [Forms]!
[frmEmployees]![EmployeeID]. When I double click the query and insert
an Employee ID, it gives me the right number. So I went into the form
and created a text box. The form itself is based on tblEmployees, so
I went into Properties of the text box, and under control source, put:
[qryEmployeesTotalHours]![SumOfHoursWorked]

When I open the form, the text box has #Name? in it.

Does anyone know what the propblem is? What I am trying to do is have
it recaculate as the user scrolls through the records (different
employees) of the Employees Form. Any help would be greatly
appreciated. If I have posted this in the wrong forum, please let me
know.

Thanks,

John
 
Ad

Advertisements

A

Allen Browne

Use DLookup() if you want a text box to read a value from a query.

The Control Source of the text box would be:
=DLookup("MyField", "MyQuery")
where you substitute the name of your field and query.

If DLookup() is new, here's more on that:
http://allenbrowne.com/casu-07.html
 
Ad

Advertisements

P

Pat Sullivan

I did the Dlookup and got it to work using ctrl G but with the query I have two sets of criteria

This is what I am trying to do.

I have a form that is used ( or going to be used if I ever get it right) that you select the store # on the main form. On the subform you select the fiscal year and the qtr and enter the information. ( wages, expenses, sales, etc)

What I want to happen is on the second column, I have blank text fields that should populate with the year to date information with a button. I have a query setup to pull the store ( from the form selection) and the fiscal year( from the subform selection) so I can get the results I need in the query but not in form.

I think that I have to do the recordset thing in code but I do not understand that at all. I have tried a few different times and someone gave me a example but it never works.

Can you tell me the best way to do this? I thought about trying to do a Dlookup for the store number ( from form) and the fiscal year (from subform) and another criteria for qtr 1 and then say plus dlookup .... qtr 2 and so on for the 4 qtrs.

Also, my dlookup takes the closest to the answer if there is not one and I need a zero, I have tried nz in front but that did not work. Wow I have given lots of information. Hopefully you can help me!

Thanks

Pat



Allen Browne wrote:

Use DLookup() if you want a text box to read a value from a query.
11-Mar-08

Use DLookup() if you want a text box to read a value from a query

The Control Source of the text box would be
=DLookup("MyField", "MyQuery"
where you substitute the name of your field and query.

Previous Posts In This Thread:

Use DLookup() if you want a text box to read a value from a query.
Use DLookup() if you want a text box to read a value from a query

The Control Source of the text box would be
=DLookup("MyField", "MyQuery"
where you substitute the name of your field and query.

John, you want to use the DLOOKUP function in your form to read the datafrom
John, you want to use the DLOOKUP function in your form to read the dat
from the query

Here is a tutorial on DLOOKUP

http://www.599cd.com/tips/access/dlookup-function


I hope this helps you. L

Query Results in Text Box
Hello

I have an existing form with employee data. I have just finishe
building a query that is a summation of the hours that an employee ha
worked at the company. It is a totals query so it alwa

Thanks Guys. I appreciate the help.John
Thanks Guys. I appreciate the help

John

EggHeadCafe - Software Developer Portal of Choice
Recursively Finding All Controls of a specified Type via Generics
http://www.eggheadcafe.com/tutorial...b-c8aed910ef60/recursively-finding-all-c.aspx
 

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

Similar Threads


Top