Creini
09-25-2008, 09:13 PM
Hi,
I'm having a bit of an issue with TextBoxes that use a Function as a Control. What happens is that if I want to get the value of the textbox it will run the function, not just give me the value. Which is fine if you don't do a lot of stuff. But my function does a few things and get called quite a few times, and calling it twice seems a bit excessive. Is there a way to not do this but instead just read the value of the bound textbox?
What I'm trying to do is make a table and then sum the columns of the table. Each table is a row, and 8 fields in the row call a function that calculates a number of exception with various criteria, and then returns that number.
To sum I have a couple of variables that add the value of each field of each row as they are created (Detail_Print)
Private Sub Detail_Print(Cancel As Integer, FormatCount As Integer)
MaintenanceSum = MaintenanceSum + Val(Me.MaintenanceNew)
SevereSum = SevereSum + Val(Me.SevereNew)
ImmediateSum = ImmediateSum + Val(Me.ImmediateNew)
TotalSum = TotalSum + Val(Me.TotalNew)
MaintenanceSumOld = MaintenanceSumOld + Val(Me.MaintenanceOld)
SevereSumOld = SevereSumOld + Val(Me.SevereOld)
ImmediateSumOld = ImmediateSumOld + Val(Me.ImmediateOld)
TotalSumOld = TotalSumOld + Val(Me.TotalOld)
End Sub
But each time it does this it runs the Function that's in the SQL query.
The query looks something like this (but a bit longer).
SELECT Exception, MyFunction(aaaa) as A, MyFunction(bbbb) as B From ExceptionsTable
If I only run the query it works fine, just when I try to set a value to be the same value as my bound textbox it runs it twice.
Is ther away around this?
Thanks,
Mattias
I'm having a bit of an issue with TextBoxes that use a Function as a Control. What happens is that if I want to get the value of the textbox it will run the function, not just give me the value. Which is fine if you don't do a lot of stuff. But my function does a few things and get called quite a few times, and calling it twice seems a bit excessive. Is there a way to not do this but instead just read the value of the bound textbox?
What I'm trying to do is make a table and then sum the columns of the table. Each table is a row, and 8 fields in the row call a function that calculates a number of exception with various criteria, and then returns that number.
To sum I have a couple of variables that add the value of each field of each row as they are created (Detail_Print)
Private Sub Detail_Print(Cancel As Integer, FormatCount As Integer)
MaintenanceSum = MaintenanceSum + Val(Me.MaintenanceNew)
SevereSum = SevereSum + Val(Me.SevereNew)
ImmediateSum = ImmediateSum + Val(Me.ImmediateNew)
TotalSum = TotalSum + Val(Me.TotalNew)
MaintenanceSumOld = MaintenanceSumOld + Val(Me.MaintenanceOld)
SevereSumOld = SevereSumOld + Val(Me.SevereOld)
ImmediateSumOld = ImmediateSumOld + Val(Me.ImmediateOld)
TotalSumOld = TotalSumOld + Val(Me.TotalOld)
End Sub
But each time it does this it runs the Function that's in the SQL query.
The query looks something like this (but a bit longer).
SELECT Exception, MyFunction(aaaa) as A, MyFunction(bbbb) as B From ExceptionsTable
If I only run the query it works fine, just when I try to set a value to be the same value as my bound textbox it runs it twice.
Is ther away around this?
Thanks,
Mattias