PC Review


Reply
Thread Tools Rate Thread

Convert CombineChildRecord code from DAO to ADO?

 
 
ChazD
Guest
Posts: n/a
 
      25th Jul 2008
Hi All,

The article at

http://support.microsoft.com/kb/318642/EN-US/

contains DAO code to combine child records; however, 2007 uses ADO and I
don't know how to convert. I'd appreciate any assistance this community
could give. I've copied and pasted the code below for convenience.

Thanks in Advance,
ChazD

Function CombineChildRecords(strTblQryIn As String, _
strFieldNameIn As String, strLinkChildFieldNameIn As String, _
varPKVvalue As Variant, Optional strDelimiter) As Variant

Dim db As DAO.Database
Dim qd As DAO.QueryDef
Dim rs As DAO.Recordset
Dim strSQL As String
Dim varResult As Variant

Set db = CurrentDb
Set qd = db.CreateQueryDef("")

If IsMissing(strDelimiter) Then strDelimiter = "; "
strSQL = "SELECT [" & strFieldNameIn & "] FROM [" & strTblQryIn & "]"
qd.SQL = strSQL & " WHERE [" & strLinkChildFieldNameIn & "] = [ParamIn]"
qd.Parameters("ParamIn").Value = varPKVvalue

Set rs = qd.OpenRecordset()

Do Until rs.EOF
varResult = varResult & rs.Fields(strFieldNameIn).Value & strDelimiter
rs.MoveNext
Loop

rs.Close

If Len(varResult) > 0 Then varResult = Left$(varResult, _
Len(varResult) - 2)

CombineChildRecords = varResult

Set rs = Nothing
Set qd = Nothing
Set db = Nothing
End Function
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Linq to XML--Are there code examples that make Linq as easy as SQL? Or how can I convert ths simple pseudo code into real code? Reece Microsoft C# .NET 4 10th Dec 2008 03:13 AM
Excel code convert to Access code - Concat & eliminate duplicates italia Microsoft Access Queries 1 12th Sep 2006 07:22 PM
Excel code convert to Access code - Concat & eliminate duplicates italia Microsoft Access 2 12th Sep 2006 06:13 PM
Excel code convert to Access code - Concat & eliminate duplicates italia Microsoft Access Macros 0 12th Sep 2006 05:04 PM
Excel code convert to Access code - Concat & eliminate duplicates italia Microsoft Excel Programming 1 12th Sep 2006 12:14 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:42 AM.