Hi
I wrote this. Is it correct
I split the qry_Pedigree into 2 query's Mothers Side and Fathers Side
( qry_Pedigree_Father & qry_Pedigree_Mother ) and then made another (qry_Pedgree) query joining the 2.
Created a table with 1 field (RingNumber)
Could i have done it with an array
--------------------------------------------------------
Public Function GetAVK(RingNumber As String)
On Error GoTo TestButton_Click_Error
Dim db As DAO.Database
Dim rs, rstPedigree As DAO.Recordset
Dim ii As Integer
Dim ss As String
Dim BirdPair, i, x, varCount As Byte
Dim varAVK As Double
DoCmd.OpenQuery ("qry_DelPedigree")
BirdPair = GetPairID(GetID(RingNumber))
Set db = CurrentDb
Set rs = db.OpenRecordset("qry_Pedgree")
rs.MoveLast
rs.MoveFirst
rs.FindFirst "[PairID] = " & BirdPair
i = 0: x = 0
For ii = 2 To rs.Fields.Count - 1
ss = Nz(rs.Fields(ii).Value, "Nill")
varCount = DCount("[RingNumber]", "tbl_Pedigree", "RingNumber = " & q & ss & q)
If varCount > 0 Then i = i + 1
If ss <> "Nill" Then
x = x + 1
Set rstPedigree = CurrentDb.OpenRecordset("tbl_Pedigree")
rstPedigree.AddNew
rstPedigree("RingNumber").Value = ss
rstPedigree.Update
rstPedigree.Close
Set rstPedigree = Nothing
End If
Next ii
GetAVK = Round((100 / x) * (x - i), 3)
Exit Function
On Error GoTo 0
Exit Function
TestButton_Click_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure TestButton_Click, line " & Erl & "."
End Function