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.

Go Back   { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Access

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-12-2008, 07:49 AM
Bob Vance
 
Posts: n/a
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


Reply With Quote
  #2 (permalink)  
Old 08-12-2008, 08:13 AM
pietlinden@hotmail.com
 
Posts: n/a
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...
Reply With Quote
  #3 (permalink)  
Old 08-12-2008, 09:18 AM
Bob Vance
 
Posts: n/a
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...


Reply With Quote
Reply

  { mindfrost82.com } > Gadget Corner > Tech Newsgroups > Microsoft > MS Office > Access


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 04:37 PM.


Powered by vBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
© 1999-2008 mindfrost82.com v11.0


Sponsors:
Mortgage | Mortgages | Foros informatico | Personal Loans | Dirty Dozen Brass Band



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114