B
Bob V
This function gives the ,father,mother.age,sex to a horse if he has no name
or if named shows his Name, I want to add one field to both Names the field
is called "Extra"
Thanks for any help ..................Bob
Function funGetHorseName(lngInvoiceID As Long, lngHorseID As Long) As String
Dim recHorseName As New ADODB.Recordset, strAge As String, strName As String
recHorseName.Open "SELECT * FROM tblInvoice WHERE InvoiceID=" _
& lngInvoiceID & " AND HorseID=" & lngHorseID,
CurrentProject.Connection, adOpenDynamic, adLockOptimistic
If recHorseName.EOF = True And recHorseName.BOF = True Then
Set recHorseName = Nothing
funGetHorseName = ""
Exit Function
End If
If IsNull(recHorseName.Fields("DateOfBirth")) Or
recHorseName.Fields("DateOfBirth") = "" Then
strAge = "0yo"
Else
strAge = funCalcAge(Format("01-Aug-" &
Year(recHorseName.Fields("DateOfBirth")), "dd-mmm-yyyy"), Format(Now(),
"dd-mmm-yyyy"), 1)
End If
strName = Nz(recHorseName.Fields("FatherName"), "") & "--" &
Nz(recHorseName.Fields("MotherName"), "") _
& "--" & strAge & "-" & Nz(recHorseName.Fields("Sex"), "")
Set recHorseName = Nothing
Debug.Print strName
funGetHorseName = strName
End Function
or if named shows his Name, I want to add one field to both Names the field
is called "Extra"
Thanks for any help ..................Bob
Function funGetHorseName(lngInvoiceID As Long, lngHorseID As Long) As String
Dim recHorseName As New ADODB.Recordset, strAge As String, strName As String
recHorseName.Open "SELECT * FROM tblInvoice WHERE InvoiceID=" _
& lngInvoiceID & " AND HorseID=" & lngHorseID,
CurrentProject.Connection, adOpenDynamic, adLockOptimistic
If recHorseName.EOF = True And recHorseName.BOF = True Then
Set recHorseName = Nothing
funGetHorseName = ""
Exit Function
End If
If IsNull(recHorseName.Fields("DateOfBirth")) Or
recHorseName.Fields("DateOfBirth") = "" Then
strAge = "0yo"
Else
strAge = funCalcAge(Format("01-Aug-" &
Year(recHorseName.Fields("DateOfBirth")), "dd-mmm-yyyy"), Format(Now(),
"dd-mmm-yyyy"), 1)
End If
strName = Nz(recHorseName.Fields("FatherName"), "") & "--" &
Nz(recHorseName.Fields("MotherName"), "") _
& "--" & strAge & "-" & Nz(recHorseName.Fields("Sex"), "")
Set recHorseName = Nothing
Debug.Print strName
funGetHorseName = strName
End Function