robjones23
Registered User.
- Local time
- Today, 20:00
- Joined
- Dec 16, 2004
- Messages
- 66
Hello All,
I've got a database which has several fields but the ones I'm interested in are:
Seconds1 Sev Seconds2 Sev2 Seconds3 Sev3 etc...
Basically Seconds 1 holds a number in seconds of outage time, Sev tells me which severity the incident was at at the time. So for example the database would look like this:
14756, 3, 749, 5, 7468, 1, 9974, 1
What I want is for Some code to look at each row in the table and where it sees a "1" "2" "3" "4" "5" in Sev it adds up the figures and then returns this:
"Time at Sev1 XX:XX, time at Sev2 YY:YY" etc....
At the mo I'm trying to get it working for Sev1 only using the following code:
This works fine for the first row but all the other rows return #Error. I'm assuming this is because I need to "restart" the function for each row?? I don't know how to do that!! Can anyone help??
This might be a dirty way to do it so any other ideas would be welcomed
Note that I'm trying to get the sev1 bit working first and then replicate that for other severities which is why there are unused bits there
Cheers,
Rob.
I've got a database which has several fields but the ones I'm interested in are:
Seconds1 Sev Seconds2 Sev2 Seconds3 Sev3 etc...
Basically Seconds 1 holds a number in seconds of outage time, Sev tells me which severity the incident was at at the time. So for example the database would look like this:
14756, 3, 749, 5, 7468, 1, 9974, 1
What I want is for Some code to look at each row in the table and where it sees a "1" "2" "3" "4" "5" in Sev it adds up the figures and then returns this:
"Time at Sev1 XX:XX, time at Sev2 YY:YY" etc....
At the mo I'm trying to get it working for Sev1 only using the following code:
Code:
Public Function Sevcalc(secondsa As Integer, Seva As Integer, secondsb As Integer, Sevb As Integer, secondsc As Integer, Sevc As Integer, secondsd As Integer, Sevd As Integer) As String
Dim secs1a As Integer
Dim secs1b As Integer
Dim secs1c As Integer
Dim secs1d As Integer
Dim Secs1Total As String
Dim secs2 As Integer
Dim secs3 As Integer
Dim secs4 As Integer
If Seva = 1 Then
secs1a = secondsa
End If
If Sevb = 1 Then
secs1b = secondsb
End If
If Sevc = 1 Then
secs1c = secondsc
End If
If Sevd = 1 Then
secs1d = secondsd
End If
Secs1Total = HoursAndMinutes((secs1a + secs1b + secs1c + secs1d) / 1440 / 60)
Sevcalc = "Time at Sev1" & " " & Secs1Total
End Function
This works fine for the first row but all the other rows return #Error. I'm assuming this is because I need to "restart" the function for each row?? I don't know how to do that!! Can anyone help??
This might be a dirty way to do it so any other ideas would be welcomed
Note that I'm trying to get the sev1 bit working first and then replicate that for other severities which is why there are unused bits there
Cheers,
Rob.