![]() |
|
|
Welcome to the { mindfrost82.com } forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Add to a String Help
This is what I have so far but sometimes Horses have not got a HorseName yet
so I would like the Father,Mother,Sex to show instead! idHorse = Nz(Me.tbHorseID, 0) If idHorse <> 0 Then strHorse = Nz(DLookup("[HorseName]", "tblHorseInfo", "[HorseID]=" & idHorse), "") Else strHorse = "" End If ------------------------------------ But if "[HorseName]" = "" strHorse = Nz(DLookup("[FatherName]", "tblHorseInfo", "[HorseID]=" & idHorse), "") & strHorse = Nz(DLookup("[MotherName]", "tblHorseInfo", "[HorseID]=" & idHorse), "") & strHorse = Nz(DLookup("[Sex]", "tblHorseInfo", "[HorseID]=" & idHorse), "") -- Thanks in advance for any help with this......Bob WindowsXP..MS Access 2007 |
|
|||
|
Re: Add to a String Help
On Aug 12, 1:49*am, "Bob Vance" <rjva...@ihug.co.nz> wrote:
> This is what I have so far but sometimes Horses have not got a HorseName yet > so I would like the Father,Mother,Sex to show instead! > idHorse = Nz(Me.tbHorseID, 0) > * * If idHorse <> 0 Then > * * * * strHorse = Nz(DLookup("[HorseName]", "tblHorseInfo", "[HorseID]=" & > idHorse), "") > * * Else > * * * * strHorse = "" > * * End If > ------------------------------------ > > But if "[HorseName]" = "" > *strHorse = Nz(DLookup("[FatherName]", "tblHorseInfo", "[HorseID]="& > idHorse), "") & > *strHorse = Nz(DLookup("[MotherName]", "tblHorseInfo", "[HorseID]="& > idHorse), "") & > *strHorse = Nz(DLookup("[Sex]", "tblHorseInfo", "[HorseID]=" & idHorse), "") > > -- > Thanks in advance for any help with this......Bob > WindowsXP..MS Access 2007 Here's the structure for the Sire/Dam part... http://www.allenbrowne.com/ser-06.html then the query should do what you want... |
|
|||
|
Re: Add to a String Help
Thanks Peter but i will run a query from this that will give either name or
breeding Thanks 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 <pietlinden@hotmail.com> wrote in message news:40002de2-f01d-4e6d-a9ab-2634fd19de6d@25g2000hsx.googlegroups.com... On Aug 12, 1:49 am, "Bob Vance" <rjva...@ihug.co.nz> wrote: > This is what I have so far but sometimes Horses have not got a HorseName > yet > so I would like the Father,Mother,Sex to show instead! > idHorse = Nz(Me.tbHorseID, 0) > If idHorse <> 0 Then > strHorse = Nz(DLookup("[HorseName]", "tblHorseInfo", "[HorseID]=" & > idHorse), "") > Else > strHorse = "" > End If > ------------------------------------ > > But if "[HorseName]" = "" > strHorse = Nz(DLookup("[FatherName]", "tblHorseInfo", "[HorseID]=" & > idHorse), "") & > strHorse = Nz(DLookup("[MotherName]", "tblHorseInfo", "[HorseID]=" & > idHorse), "") & > strHorse = Nz(DLookup("[Sex]", "tblHorseInfo", "[HorseID]=" & idHorse), > "") > > -- > Thanks in advance for any help with this......Bob > WindowsXP..MS Access 2007 Here's the structure for the Sire/Dam part... http://www.allenbrowne.com/ser-06.html then the query should do what you want... |
![]() |
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|