-
-
why this sum function won't work ?
-
eg Sum(personal)
-
lblPersonal.Caption it wont retrieve the sum value of the personal field
-
-
Dim cn6 As New ADODB.Connection
-
Dim strCNString4 As String
-
Dim rs6 As New ADODB.Recordset
-
Dim intFound6 As Double
-
-
strCNString6 = "Data Source=" & App.Path & "\PayrollBakeryDB.mdb"
-
cn6.Provider = "Microsoft Jet 4.0 OLE DB Provider"
-
cn6.ConnectionString = strCNString6
-
-
cn6.Open
-
-
With rs6
-
'.Open "SELECT Sum(personal), Sum(sick), Sum(vacation), Sum(maternity), emp_id, from_date, to_date FROM leavela WHERE Month(from_date)=" & intMonth & " and Year(from_date)=" & intYear & " and Month(to_date)=" & intMonth & " and Year(to_date)=" & intYear & " GROUP BY emp_id, from_date, to_date ", cn6, adOpenDynamic, adLockOptimistic
-
-
Do Until .EOF
-
-
If !emp_id = txtEmp_ID.Text Then
-
lblPersonal.Caption = rs6.Fields(0) 'here
-
lblSick.Caption = rs6.Fields(1) 'here
-
Vacation.Caption = rs6.Fields(2) 'here
-
lblMaternity.Caption = rs6.Fields(3) 'here
-
-
intFound6 = 1
-
End If
-
-
.MoveNext
-
Loop
-
-
'If intFound6 = 0 Then
-
'MsgBox "Employee ID not found !", vbExclamation, "Error"
-
'End If
-
-
End With
-
-
2 2115 -
-
why this sum function won't work ?
-
eg Sum(personal)
-
lblPersonal.Caption it wont retrieve the sum value of the personal field
-
-
Dim cn6 As New ADODB.Connection
-
Dim strCNString4 As String
-
Dim rs6 As New ADODB.Recordset
-
Dim intFound6 As Double
-
-
strCNString6 = "Data Source=" & App.Path & "\PayrollBakeryDB.mdb"
-
cn6.Provider = "Microsoft Jet 4.0 OLE DB Provider"
-
cn6.ConnectionString = strCNString6
-
-
cn6.Open
-
-
With rs6
-
'.Open "SELECT Sum(personal), Sum(sick), Sum(vacation), Sum(maternity), emp_id, from_date, to_date FROM leavela WHERE Month(from_date)=" & intMonth & " and Year(from_date)=" & intYear & " and Month(to_date)=" & intMonth & " and Year(to_date)=" & intYear & " GROUP BY emp_id, from_date, to_date ", cn6, adOpenDynamic, adLockOptimistic
-
-
Do Until .EOF
-
-
If !emp_id = txtEmp_ID.Text Then
-
lblPersonal.Caption = rs6.Fields(0) 'here
-
lblSick.Caption = rs6.Fields(1) 'here
-
Vacation.Caption = rs6.Fields(2) 'here
-
lblMaternity.Caption = rs6.Fields(3) 'here
-
-
intFound6 = 1
-
End If
-
-
.MoveNext
-
Loop
-
-
'If intFound6 = 0 Then
-
'MsgBox "Employee ID not found !", vbExclamation, "Error"
-
'End If
-
-
End With
-
-
- Are the sure the Recordset is returning any Records?
- Is the following condition ever being met? (!emp_id = txtEmp_ID.Text )
- Change the syntax of the following line of code:
- !emp_id = txtEmp_ID.Text ==> !emp_id = Me![txtEmp_ID]
-
NOTE: The Text property is only valid when the Field has the focus.
Best to try the query first in the query editor. (Use a breakpoint and F8 to step through the code and type in the immediate window a "?" followed by the stringing to get the result in textmode for a copy/paste in the query editor.)
Next it's better to use:
Sum(NZ(personal))
as Null values can spoil the result.
Nic;o)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ben |
last post by:
Hi all,
I'm trying to figure out how how complex map, filter and reduce work
based on the following piece of code from
http://www-106.ibm.com/developerworks/linux/library/l-prog.html :
...
|
by: ajj |
last post by:
Hello All,
Yes this is homework, but I have spent a lot of time on it and I am
close.
I want to be able to count the number of nodes in a tree that have only
one child.
I can identify the...
|
by: Peter Ammon |
last post by:
Howdy,
I have four unsigned long longs a, b, c, d. I want to determine whether
a+b or c+d is larger, as if there were no overflow. That is, ULLONG_MAX
+ 5 should be considered larger than 10 +...
|
by: DAHMB |
last post by:
I have a column in a report that I want to return a sum of certain criteria from a query between two dates. I set the dates in a form that I launch the report from.
My query contains a field...
|
by: n8kindt |
last post by:
i don't know what to do about this one. there are some very strange things going on. i have a continuous form with a bound textbox and a bound toggle button. the textbox is named "Payment" and the...
|
by: bearophileHUGS |
last post by:
Empty Python lists don't know the type of the items it will
contain, so this sounds strange:
0
Because that may be an empty sequence of someobject:
0
In a statically typed language in...
|
by: azegurb |
last post by:
hi
I have just took from internet dinamic table. this table is dynamic and its rows dynamically can be increased.
but i would like how create SUM function that automatically sums each added row...
|
by: azegurb |
last post by:
Hello, I have one question again
i created one table again and in this table i added some another options
for ex at the previous table there were only one problem sum of the dynamically added...
|
by: merkam |
last post by:
hi,
i need a script that:
step1: multiple n*1200= m
n=0 or 1 or 2 ...
step2: sum m+10+20
i have this script
i don't now how to assign span with id="five" to value in checkbox plz help me
<%@...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |