Noob here. I did try Search first.
I have an MS Access app developed 2005. Now running it in 2007.
I have a query that calls a procedure:
bakRoundData is a procedure from a public module. It returns calculations with specified significant figures (in this case, 3 sig figs). The procedure is below -- apologies for losing the indents.
Anyway, the code works fine in Access 2005, but I can't get it to run in 2007. I don't get any errors, it just doesn't work -- the answer table has 8-digit values. When I put a breakpoint in the code, it stops but only several moments after the answer table is generated; and I apparently can step through the code right but that doesn't change the answer table. I tried putting an error in the procedure, compiling (caught the error), fixing it, and recompiling (I mean, I forced a recompile), but it still doesn't work. I haven't yet tested this procedure in other contexts -- will do that now.
I use this query as the recordsource for a report. Is there some option that I need to check in Access 2007 to make this work?
Hope this is enough info.
--
Nails1 (normally Nails, but there appears to be another one already on this forum)
I have an MS Access app developed 2005. Now running it in 2007.
I have a query that calls a procedure:
cfs: bakRoundData((tblDischarge.WaterDischargeRateMeasure*35.3147),3)
The field name "cfs" is a water flow measurement that I'm converting from "cms", which is what the table stores as "WaterDischargeRateMeasure" (converting to cubic feet per second from cubic meters per second).bakRoundData is a procedure from a public module. It returns calculations with specified significant figures (in this case, 3 sig figs). The procedure is below -- apologies for losing the indents.
Anyway, the code works fine in Access 2005, but I can't get it to run in 2007. I don't get any errors, it just doesn't work -- the answer table has 8-digit values. When I put a breakpoint in the code, it stops but only several moments after the answer table is generated; and I apparently can step through the code right but that doesn't change the answer table. I tried putting an error in the procedure, compiling (caught the error), fixing it, and recompiling (I mean, I forced a recompile), but it still doesn't work. I haven't yet tested this procedure in other contexts -- will do that now.
I use this query as the recordsource for a report. Is there some option that I need to check in Access 2007 to make this work?
Hope this is enough info.
--
Nails1 (normally Nails, but there appears to be another one already on this forum)
Public Function bakRoundData(inputData As Single, selectedSigFig As Byte) As Single
On Error GoTo ErrorHandler
Dim fTrimData As Boolean
Dim sngTrimData As Single
If inputData = 0 Then
bakRoundData = 0
Else
If selectedSigFig = 0 Then
fTrimData = True
selectedSigFig = 3
Else
fTrimData = False
End If
Select Case inputData
Case Is < 0.00000001
If inputData = 0 Then
bakRoundData = 0
GoTo ExitProc
Else
sngTrimData = 8 + selectedSigFig
bakRoundData = Round(inputData, sngTrimData)
End If
Case Is < 0.0000001
sngTrimData = 7 + selectedSigFig
bakRoundData = Round(inputData, sngTrimData)
Case Is < 0.000001
sngTrimData = 6 + selectedSigFig
bakRoundData = Round(inputData, sngTrimData)
Case Is < 0.00001
sngTrimData = 5 + selectedSigFig
bakRoundData = Round(inputData, sngTrimData)
Case Is < 0.0001
sngTrimData = 4 + selectedSigFig
bakRoundData = Round(inputData, sngTrimData)
Case Is < 0.001
sngTrimData = 3 + selectedSigFig
bakRoundData = Round(inputData, sngTrimData)
Case Is < 0.01
sngTrimData = 2 + selectedSigFig
bakRoundData = Round(inputData, sngTrimData)
Case Is < 0.1
sngTrimData = 1 + selectedSigFig
bakRoundData = Round(inputData, sngTrimData)
Case Is < 1
sngTrimData = selectedSigFig
bakRoundData = Round(inputData, sngTrimData)
Case Is < 10
sngTrimData = -1 + selectedSigFig
If sngTrimData < 0 Then
bakRoundData = Round(inputData * (10 ^ sngTrimData), 0) / (10 ^ sngTrimData)
Else
bakRoundData = Round(inputData, sngTrimData)
End If
Case Is < 100
sngTrimData = -2 + selectedSigFig
If sngTrimData < 0 Then
bakRoundData = Round(inputData * (10 ^ sngTrimData), 0) / (10 ^ sngTrimData)
Else
bakRoundData = Round(inputData, sngTrimData)
End If
Case Is < 1000
sngTrimData = -3 + selectedSigFig
If sngTrimData < 0 Then
bakRoundData = Round(inputData * (10 ^ sngTrimData), 0) / (10 ^ sngTrimData)
Else
bakRoundData = Round(inputData, sngTrimData)
End If
Case Is < 10000
sngTrimData = -4 + selectedSigFig
If sngTrimData < 0 Then
bakRoundData = Round(inputData * (10 ^ sngTrimData), 0) / (10 ^ sngTrimData)
Else
bakRoundData = Round(inputData, sngTrimData)
End If
Case Is < 100000
sngTrimData = -5 + selectedSigFig
If sngTrimData < 0 Then
bakRoundData = Round(inputData * (10 ^ sngTrimData), 0) / (10 ^ sngTrimData)
Else
bakRoundData = Round(inputData, sngTrimData)
End If
Case Is < 1000000
sngTrimData = -6 + selectedSigFig
If sngTrimData < 0 Then
bakRoundData = Round(inputData * (10 ^ sngTrimData), 0) / (10 ^ sngTrimData)
Else
bakRoundData = Round(inputData, sngTrimData)
End If
Case Is < 10000000
sngTrimData = -7 + selectedSigFig
If sngTrimData < 0 Then
bakRoundData = Round(inputData * (10 ^ sngTrimData), 0) / (10 ^ sngTrimData)
Else
bakRoundData = Round(inputData, sngTrimData)
End If
Case Is < 100000000
sngTrimData = -8 + selectedSigFig
If sngTrimData < 0 Then
bakRoundData = Round(inputData * (10 ^ sngTrimData), 0) / (10 ^ sngTrimData)
Else
bakRoundData = Round(inputData, sngTrimData)
End If
Case Else
bakRoundData = inputData
End Select
If bakRoundData = 0 Then
bakRoundData = inputData
End If
End If
ExitProc:
Exit Function
ErrorHandler:
Call bakErrorHandler(Err.Number, Err.Description, "basBackEndStuff.bakRoundData")
Resume ExitProc
End Function
On Error GoTo ErrorHandler
Dim fTrimData As Boolean
Dim sngTrimData As Single
If inputData = 0 Then
bakRoundData = 0
Else
If selectedSigFig = 0 Then
fTrimData = True
selectedSigFig = 3
Else
fTrimData = False
End If
Select Case inputData
Case Is < 0.00000001
If inputData = 0 Then
bakRoundData = 0
GoTo ExitProc
Else
sngTrimData = 8 + selectedSigFig
bakRoundData = Round(inputData, sngTrimData)
End If
Case Is < 0.0000001
sngTrimData = 7 + selectedSigFig
bakRoundData = Round(inputData, sngTrimData)
Case Is < 0.000001
sngTrimData = 6 + selectedSigFig
bakRoundData = Round(inputData, sngTrimData)
Case Is < 0.00001
sngTrimData = 5 + selectedSigFig
bakRoundData = Round(inputData, sngTrimData)
Case Is < 0.0001
sngTrimData = 4 + selectedSigFig
bakRoundData = Round(inputData, sngTrimData)
Case Is < 0.001
sngTrimData = 3 + selectedSigFig
bakRoundData = Round(inputData, sngTrimData)
Case Is < 0.01
sngTrimData = 2 + selectedSigFig
bakRoundData = Round(inputData, sngTrimData)
Case Is < 0.1
sngTrimData = 1 + selectedSigFig
bakRoundData = Round(inputData, sngTrimData)
Case Is < 1
sngTrimData = selectedSigFig
bakRoundData = Round(inputData, sngTrimData)
Case Is < 10
sngTrimData = -1 + selectedSigFig
If sngTrimData < 0 Then
bakRoundData = Round(inputData * (10 ^ sngTrimData), 0) / (10 ^ sngTrimData)
Else
bakRoundData = Round(inputData, sngTrimData)
End If
Case Is < 100
sngTrimData = -2 + selectedSigFig
If sngTrimData < 0 Then
bakRoundData = Round(inputData * (10 ^ sngTrimData), 0) / (10 ^ sngTrimData)
Else
bakRoundData = Round(inputData, sngTrimData)
End If
Case Is < 1000
sngTrimData = -3 + selectedSigFig
If sngTrimData < 0 Then
bakRoundData = Round(inputData * (10 ^ sngTrimData), 0) / (10 ^ sngTrimData)
Else
bakRoundData = Round(inputData, sngTrimData)
End If
Case Is < 10000
sngTrimData = -4 + selectedSigFig
If sngTrimData < 0 Then
bakRoundData = Round(inputData * (10 ^ sngTrimData), 0) / (10 ^ sngTrimData)
Else
bakRoundData = Round(inputData, sngTrimData)
End If
Case Is < 100000
sngTrimData = -5 + selectedSigFig
If sngTrimData < 0 Then
bakRoundData = Round(inputData * (10 ^ sngTrimData), 0) / (10 ^ sngTrimData)
Else
bakRoundData = Round(inputData, sngTrimData)
End If
Case Is < 1000000
sngTrimData = -6 + selectedSigFig
If sngTrimData < 0 Then
bakRoundData = Round(inputData * (10 ^ sngTrimData), 0) / (10 ^ sngTrimData)
Else
bakRoundData = Round(inputData, sngTrimData)
End If
Case Is < 10000000
sngTrimData = -7 + selectedSigFig
If sngTrimData < 0 Then
bakRoundData = Round(inputData * (10 ^ sngTrimData), 0) / (10 ^ sngTrimData)
Else
bakRoundData = Round(inputData, sngTrimData)
End If
Case Is < 100000000
sngTrimData = -8 + selectedSigFig
If sngTrimData < 0 Then
bakRoundData = Round(inputData * (10 ^ sngTrimData), 0) / (10 ^ sngTrimData)
Else
bakRoundData = Round(inputData, sngTrimData)
End If
Case Else
bakRoundData = inputData
End Select
If bakRoundData = 0 Then
bakRoundData = inputData
End If
End If
ExitProc:
Exit Function
ErrorHandler:
Call bakErrorHandler(Err.Number, Err.Description, "basBackEndStuff.bakRoundData")
Resume ExitProc
End Function