473,320 Members | 2,098 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to show a query result on a form

Hi Everyone

I have a query which shows total number of hours and I want to display this information on a form (as a text box or a label).

How can I do it?

Thanks in advance
Dec 7 '07 #1
13 21392
puppydogbuddy
1,923 Expert 1GB
Hi Everyone

I have a query which shows total number of hours and I want to display this information on a form (as a text box or a label).

How can I do it?

Thanks in advance
You can use the DLookup function as follows:

YourTextbox = DLookup("[TotalHours]" , "YourQuery")

The DLookup rather than DSum was used because the You stated that the summation is done in the query itself.
Dec 7 '07 #2
Thanks for the reply it is working :)

What I need to do now is to show total field on the form based on a query where there are 7 different rows [employeeID] and I need to extract the total of the employeeID which is choosen from the combo box on the form.

Any ideas how to do it?

Thanks in Advance
Dec 8 '07 #3
puppydogbuddy
1,923 Expert 1GB
Thanks for the reply it is working :)

What I need to do now is to show total field on the form based on a query where there are 7 different rows [employeeID] and I need to extract the total of the employeeID which is choosen from the combo box on the form.

Any ideas how to do it?

Thanks in Advance
Again, I am using DLookup rather than DSum because, if I understand you correctly, your query has the total for each employeeID, hence you just need to look up that total. You would use DSum if the query has several entries for each employeeID that have to be totaled.

try this if EmployeeID is a numeric data type in your table.

YourTextbox2 = DLookup("[TotalHours]" , "YourQuery", "[EmployeeID] = " & Me!YourCombo)

try this if EmployeeID is a text data type in your table.

YourTextbox2 = DLookup("[TotalHours]" , "YourQuery", "[EmployeeID] = '" & Me!YourCombo & "'")
Dec 8 '07 #4
Thanks so much!!!! Functions will make my work so much easier :)
Dec 8 '07 #5
I tried to use the function but I have an error #name? when I used me!combo8 (in my case)?

I presume the problem occurs because the combo box holds a string value and the query shows a string values but it is an integer.

The function is working when I replace me!combo8 with number 18 (John)

Any ideas???
Dec 9 '07 #6
puppydogbuddy
1,923 Expert 1GB
I tried to use the function but I have an error #name? when I used me!combo8 (in my case)?

I presume the problem occurs because the combo box holds a string value and the query shows a string values but it is an integer.

The function is working when I replace me!combo8 with number 18 (John)

Any ideas???
Place your table in design view and look up the data type of EmployeeID. Depending on the data type show, choose the applicable one of the two syntaxes I gave you. If the numeric syntax does not work, then try the text syntax. If neither work, I suspect that you misspelled object name or used the wrong case (object names are case sensitive).
Dec 9 '07 #7
I do realise that I could have made a mistake (misspelled control etc) but I cannot find it.

if anyone is interested I can send a sample *.mdb
***email removed by moderator***

Thank you for your patience.
Emil
Dec 9 '07 #8
puppydogbuddy
1,923 Expert 1GB
If the function is working when you replace me!combo8 with number 18 (John)

Try these suggestions one at a time.
1. When you typed the syntax I gave you, did you include the ampersand & as shown in the example?
2. When you checked names and spelling, did you check against the name property shown in the property sheet for that control?
3. Replace Me!combo8 in the expression with Forms!YourForm!combo8 ….use the actual name of your form in place of "YourForm"
4. You tried both syntaxes I gave you?
Dec 9 '07 #9
Hi I really want to know what I'm doing wrong, so I created a simple database and the form and here is the link.A sample
Dec 10 '07 #10
puppydogbuddy
1,923 Expert 1GB
Hi I really want to know what I'm doing wrong, so I created a simple database and the form and here is the link.A sample
I looked at your sample. The table test is different than you described above. You are trying to sum a non-numeric field. You can count it , but you can't sum it. Also, your table has no unique identifier (pimary key), which won't prevent you from using it but will cause problems later on. You need to take some of the tutorials available thru this site to learn the basics before you proceed.
Dec 10 '07 #11
My question was just to lookup a value in the query (I don't want to sum anything)

(there isn't a primary key because it is not the database I use, I just created it as a sample)

I have used the function Dlookup but when I want to lookup a value in a query based on the combo box value (me!comboboxname) I have an error #name? when I use the same function and instead of me!comboboxname I put 1 or 2 I have the correct result (check 2 text boxes below the error text box)
Dec 11 '07 #12
puppydogbuddy
1,923 Expert 1GB
My question was just to lookup a value in the query (I don't want to sum anything)

(there isn't a primary key because it is not the database I use, I just created it as a sample)

I have used the function Dlookup but when I want to lookup a value in a query based on the combo box value (me!comboboxname) I have an error #name? when I use the same function and instead of me!comboboxname I put 1 or 2 I have the correct result (check 2 text boxes below the error text box)
Emil,
OK, I understand your question now. The answer is that Me is something that you can use in code, but not in an expression involving the control source. You have to use the full reference >>>>Forms!frmTest<<<< in the expression dor the control source instead of Me.
Dec 11 '07 #13
Thanks for your help it's working now.
Dec 12 '07 #14

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Jack | last post by:
Hi, I have a form when loaded, retrieves record from an access table. Among other fields there is a check box called FinalUpdate. This is tied to a field in Access of type Yes/No. The form...
1
by: Craig M | last post by:
Hi, I've created a query that has all calculations needed, and made a report based on this. I have then made a form based on this query. What I would like to do is print only the current...
1
by: RookieDan | last post by:
Greetings fellow Accessers! Im new but in Access, but I have some background in different coding. I have a programme loading customer data into Access belonging to BMW dealers in Europe. ...
6
by: ljungers | last post by:
Hi to all and hope someone may have an answer for me. I have a Form named Cust_lukup_Form that has 3 text boxes and a click button that uses a OnClick to call Cust_lukup_Macro that runs an...
1
by: Maarten van der Cammen | last post by:
Hi, In a table I have two numeric fields (e.g. FieldA and FieldB). Both fields have double precicion (field size "double"), Format "Fixed" and Decimal places "3" since I want to calculate with...
8
siridyal
by: siridyal | last post by:
I have a wholesale website that i'm working on that shows hundreds of items that are updated from time to time. These items are kept in a mysql database with several tables. I want to let the...
1
by: abhishekdhal | last post by:
I want to create a form which is linked to a table.I want to have an extra field "search" so that I can find the desired person...the search textfield will have a corresponding button in it so that...
1
ddtpmyra
by: ddtpmyra | last post by:
how can I capture the query result in PHP? I have two queries below: # Fetch the file information $query ="update filestorage set approved ='Y' where FileID = {$id}"; $query1 ="select...
0
by: dougancil | last post by:
I have the following code in my project: Private Sub Button1_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim connectionString As String...
0
by: Jason C | last post by:
I've got a simple database in Access 2007 with a form interface. One of the forms contains subforms and uses multiple tables, currently navigation works fine. There's also several complex queries...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.