All, using 2010. I have a database which I inherited. I’m in the process of revamping it. I noticed there were a lot queries which are group named to perform calculations leading to the final calculation for a result. i.e. pre-qryPerformcalculation 1, pre-qryPeformcalcuation2…..finalCalcuations. Of course I’ve been working on these to consolidate where I can. I am now creating a form for the user interface. My question for you; is it out in left field to have many of the calculations in the queries to be performed in the form with vba instead? I can recall years ago I saw some functions called from a form to do just this. But may be some restrictions because of this need to be done with a query not a table. Just thinking out loud. For example;
Code:
Private Sub Calculate()
Dim i As Integer
Dim varFieldValue As Variant
Dim strFieldName As String
'Loop through records and calculate
Do While Not rs.EOF
varFieldValue = Null
For i = 1 To 10 Step 1
strFieldName = "r" & Format(i, "00")
If Not IsNull(rs(strFieldName)) Then
varFieldValue = rs(strFieldName)
'Done
Exit For
End If
Next
This is just a snippet of something I can remember from performing calculations in VBA. Again, I am just asking for an expert opinion.