Sign Up |  Live StatsLive Stats    Articles 35,345| Comments 159,786| Members 17,820, Newest waheguruhelpme| Online 187
Home Contact
 (Forgotten?): 
    Sikhism

   
                                                                     Your Banner Here!    

Sikh Philosophy Network » Sikh Philosophy Network » Current Affairs » Information Technology » creating a flat file (txt or excel) based on a query with one to many records

creating a flat file (txt or excel) based on a query with one to many records

Our Donation Goal : Why Donate? : Donate Today! : Donate Anonymously (ਗੁਪਤ) : Our Family of Supporters
Goal this month: 400 USD, Received: 35 USD (9%)
Please Donate...
Related Topics...
Thread Thread Starter Forum Replies Last Post
Creating a template for an Access form in Excel cathywoodford@personainternet.com Information Technology 4 28-Jul-2006 08:38 AM
Filtering records in a query based on field values in adjacent records sdisalvo Information Technology 2 28-Jul-2006 08:12 AM
How to append all records from one file to another file in Access Eric Information Technology 1 28-Jul-2006 08:09 AM
Macro Output Query to Excel - Cannot Read File Ruth Information Technology 2 11-Nov-2005 20:08 PM
Re: how to execute SQL query in excel file Junior728 Information Technology 2 03-Nov-2005 11:34 AM


Tags
creating, flat, file, txt, excel, based, query, many, records
Reply Post New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!
  #1 (permalink)  
Old 28-Jul-2006, 08:09 AM
tjay's Avatar tjay
Guest
 
Posts: n/a
   
   
creating a flat file (txt or excel) based on a query with one to many records

  Donate Today!   Email to Friend  Tell a Friend   Show Printable Version  Print   Contact sikhphilosophy.net Administraion for any Suggestions, Ideas, Feedback.  Feedback  

Register to Remove Advertisements
I am attempting to create a flat file that I need to send to a service
processor.
Problem
The file I am creating comes from a query with a one to many join. This
results in several records being reproduced for each entry in the many
table.
I need to append the unique information from the duplicate rows onto the end
of the initial record. In effect creating a record that can be exported in a
flat file as a single row.

I have scoured the access help and online resources and cannot find a
solution.
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/information-technology/10055-creating-flat-file-txt-excel-based.html
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10055

If someone can point me to a resource or example I can take it from there.

Thanks much for your help. First time poster.





 
Do share your immediate thoughts or reactions on this issue? We value your views! Login Now! or Sign Up Today! to share your views with us.. Gurfateh!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 28-Jul-2006, 08:09 AM
John Vinson's Avatar John Vinson
Guest
 
Posts: n/a
   
   
Re: creating a flat file (txt or excel) based on a query with one to many records

On Sun, 21 May 2006 1452 -0700, "tjay"
wrote:

>I need to append the unique information from the duplicate rows onto the end
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10055
>of the initial record. In effect creating a record that can be exported in a
>flat file as a single row.


You'll need some VBA code. For an example (using one field from the
"many" table, but you can adapt it) see

http://www.mvps.org/access/modules/mdl0004.htm

John W. Vinson[MVP]
Reply With Quote
  #3 (permalink)  
Old 28-Jul-2006, 08:09 AM
Tom Wickerath's Avatar Tom Wickerath
Guest
 
Posts: n/a
   
   
RE: creating a flat file (txt or excel) based on a query with one to m

Hello tjay,

First, welcome to this group as a first time poster. Here is a generic
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10055
example for the sample Northwind.mdb database. Try it out first in Northwind,
and then see if you can get it to work in your database.

Create a new module. Add Option Explicit as the second line of code to your
module, if it is not already there. Here is the reason why you want this, and
instructions on how to configure your copy of Access to always include this
in all new modules:

Always Use Option Explicit
http://www.access.qbuilt.com/html/ge...tml#VBEOptions

Click on Tools > References. You need to verify that you have a reference
set to the "Microsoft DAO 3.6 Object Library" (or version 3.51 if you are
using Access 97). If you do not see this reference selected, then scroll down
the list until you find it, and place a check to select it. Then click on OK
to back out of the references dialog.

Select the following code and copy it (Ctrl C). Paste it into your new
module, just below the line that reads Option Explicit:

Function ConcatenateRecords(lngCategoryID As Long) As String
On Error GoTo ProcError

' Input: Primary key of record in Categories table
'Returns: String containing all the related product names.

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
Dim strOut As String
Dim lngLen As Long
Const conSEP = "; "

Set db = CurrentDb
strSQL = "SELECT ProductName " _
& "FROM Products " _
& "WHERE CategoryID =" & lngCategoryID

Set rs = db.OpenRecordset(strSQL)

With rs
Do While Not (.BOF Or .EOF) = True
strOut = strOut & ![ProductName] & conSEP
.MoveNext
Loop
End With

lngLen = Len(strOut) - Len(conSEP)

If lngLen > 0 Then
ConcatenateRecords = Left$(strOut, lngLen)
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10055
Else
ConcatenateRecords = ""
End If

ExitProc:
On Error Resume Next
rs.Close: Set rs = Nothing
db.Close: Set db = Nothing
Exit Function
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, vbCritical, _
"Error in ConcatenateRecords function..."
Resume ExitProc
End Function

Click on Debug > Compile ProjectName. Hopefully, your code will compile
without any errors. VBA code is compiled when an attempt to repeat this
operation reveals that the option is grayed out (ie. unavailable).

Save your new module as "basConcatentateRecords" (without the quotes).

Create a new query. Dismiss the Add Tables dialog without adding any tables.
In query design view, click on View > SQL View. You should see the word
SELECT highlighted. Copy the following SQL statement (Ctrl C) and paste it
into the SQL view (Ctrl V), replacing the SELECT keyword:

SELECT Categories.CategoryName,
ConcatenateRecords([CategoryID]) AS ProductName
FROM Categories
ORDER BY Categories.CategoryName;

You can then switch back to the more familiar design view, if you wish, by
clicking on View > Design View. Run the query.


Tom Wickerath
Microsoft Access MVP

http://www.access.qbuilt.com/html/ex...tributors.html
http://www.access.qbuilt.com/html/search.html
__________________________________________

"tjay" wrote:

> I am attempting to create a flat file that I need to send to a service
> processor.
> Problem
> The file I am creating comes from a query with a one to many join. This
> results in several records being reproduced for each entry in the many
> table.
> I need to append the unique information from the duplicate rows onto the end
> of the initial record. In effect creating a record that can be exported in a
> flat file as a single row.
>
> I have scoured the access help and online resources and cannot find a
> solution.
>
> If someone can point me to a resource or example I can take it from there.
>
> Thanks much for your help. First time poster.

Reply With Quote
  #4 (permalink)  
Old 28-Jul-2006, 08:09 AM
tjay's Avatar tjay
Guest
 
Posts: n/a
   
   
Re: creating a flat file (txt or excel) based on a query with one to many records

Thanks guys I will give it a go


"tjay" wrote in message
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10055
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10055
news:SsKdnb4toOBAf-3ZnZ2dneKdnZydnZ2d@comcast.com...
>I am attempting to create a flat file that I need to send to a service
>processor.
> Problem
> The file I am creating comes from a query with a one to many join. This
> results in several records being reproduced for each entry in the many
> table.
> I need to append the unique information from the duplicate rows onto the
> end of the initial record. In effect creating a record that can be
> exported in a flat file as a single row.
>
> I have scoured the access help and online resources and cannot find a
> solution.
>
> If someone can point me to a resource or example I can take it from there.
>
> Thanks much for your help. First time poster.
>



Reply With Quote
  #5 (permalink)  
Old 28-Jul-2006, 08:09 AM
tjay's Avatar tjay
Guest
 
Posts: n/a
   
   
Re: creating a flat file (txt or excel) based on a query with one to many records

Ok
Both examples worked and it gave me a great deal of insight but that still
wont get me there. I most likely did not explain it well.
In the attached spreadsheet Query 2 tab has the output of my test query
shaded in yellow. the cells to the right are where I accomplished what I
needed to do with a series of functions.

The desired result rows are lined top and bottom.

You can also see a desired output on the other tab

Am I wishing for something that dont exist?


"tjay" wrote in message
news:SsKdnb4toOBAf-3ZnZ2dneKdnZydnZ2d@comcast.com...
>I am attempting to create a flat file that I need to send to a service
> processor.
> Problem
> The file I am creating comes from a query with a one to many join. This
> results in several records being reproduced for each entry in the many
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10055
> table.
> I need to append the unique information from the duplicate rows onto the
> end
> of the initial record. In effect creating a record that can be exported in
> a
> flat file as a single row.
>
> I have scoured the access help and online resources and cannot find a
> solution.
>
> If someone can point me to a resource or example I can take it from there.
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10055
>
> Thanks much for your help. First time poster.
>
>





Reply With Quote
  #6 (permalink)  
Old 28-Jul-2006, 08:09 AM
tjay's Avatar tjay
Guest
 
Posts: n/a
   
   
Re: creating a flat file (txt or excel) based on a query with one to many records

hmmmm
I posted another post with a spreadsheet attachment I guess that is not
allowed

Both examples worked fine, I am working in Access 2003
While they have some features I need I really need the output to create new
fields here is an example out put I need where additional parts for work
orders are from the sub query

testpartsheader_wo testdata parts_wo part desc cost part2 desc2 cost2
part3 desc3 cost3 part4 desc4 cost4 part5 desc5 cost5
1 testdata1 1 testpart1 1 some info 11
2 testdata2 2 testpart2 2 some info 22 testpart2 1 some info 21
3 testdata3 3 testpart3 3 some info 33 testpart3 2 some info 32
testpart3 1 some info 31
4 testdata4 4 testpart4 4 some info 44 testpart4 3 some info 43
testpart4 2 some info 42 tespart4 1 some info 41
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10055
5 testdata5 5 testpart5 5 some info 55 testpart5 4 some info 54
testpart5 3 some info 53 testpart5 2 some info 52 testpart5 1 some info 51




"tjay" wrote in message
news:SsKdnb4toOBAf-3ZnZ2dneKdnZydnZ2d@comcast.com...
>I am attempting to create a flat file that I need to send to a service
>processor.
> Problem
> The file I am creating comes from a query with a one to many join. This
> results in several records being reproduced for each entry in the many
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10055
> table.
> I need to append the unique information from the duplicate rows onto the
> end of the initial record. In effect creating a record that can be
> exported in a flat file as a single row.
>
> I have scoured the access help and online resources and cannot find a
> solution.
>
> If someone can point me to a resource or example I can take it from there.
>
> Thanks much for your help. First time poster.
>



Reply With Quote
  #7 (permalink)  
Old 28-Jul-2006, 08:09 AM
John Vinson's Avatar John Vinson
Guest
 
Posts: n/a
   
   
Re: creating a flat file (txt or excel) based on a query with one to many records

  Donate Today!  
On Sun, 21 May 2006 1820 -0700, "tjay"
wrote:

>I posted another post with a spreadsheet attachment I guess that is not
>allowed


It's certainly not encouraged. I did in fact get the spreadsheet - but
posting binary attachments is considered inappropriate in these text
newsgroups, both for bandwidth and security.

>Both examples worked fine, I am working in Access 2003
>While they have some features I need I really need the output to create new
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10055
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=10055
>fields here is an example out put I need where additional parts for work
>orders are from the sub query


So you need to take a properly normalized table, and generate a
denormalized repeating-fields spreadsheet?

There's no easy way to do so. I'd suggest that your best bet would be
to use VBA code to open the spreadsheet and loop through the records,
adding new cells in the appropriate places. I'm not well enough
skilled in Excel to do this off the top of my head - perhaps a post in
an Excel newsgroup would be better.

I do need to wonder: given that you have *the same information* in
your Access database, what purpose is served by spreading it out
horizontally on the page? Tradition?

John W. Vinson[MVP]
Reply With Quote
   Click Here to Donate Now!

Support Us!
Become a Promoter!
Gurfateh ji, you can become a SPN Promoter by Donating as little as $10 each month. With limited resources & high operational costs, your donations make it possible for us to deliver a quality website and spread the teachings of the Sri Guru Granth Sahib Ji, to serve & uplift humanity. Every contribution counts. Donate Generously. Gurfateh!
ReplyPost New Topic In This Forum Stay Connected to Sikhism, Click Here to Register Now!

Bookmarks


(View-All Members who have read this thread : 0
There are no names to display.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Tools Search
Search:

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

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

» Gurbani Jukebox
Listen to Gurbani while surfing SPN!
» Active Discussions
sikhism ਨਾਮਾ
Today 06:37 AM
2 Replies, 43 Views
sikhism need urgent advice.......
Today 05:29 AM
5 Replies, 69 Views
sikhism Sikh Diamonds Video...
Today 04:23 AM
6 Replies, 112 Views
sikhism Who is "Mohan"?
Today 03:58 AM
20 Replies, 315 Views
sikhism Are Creator and Creation...
Today 01:30 AM
44 Replies, 2,829 Views
sikhism Herman Hesse,...
Today 00:54 AM
13 Replies, 225 Views
sikhism On a Scale of Most...
Yesterday 21:42 PM
30 Replies, 1,271 Views
sikhism I became victim by...
Yesterday 19:50 PM
0 Replies, 39 Views
sikhism How important is Matha...
By Ishna
Yesterday 19:05 PM
58 Replies, 1,025 Views
sikhism Sikh Books downloads
Yesterday 15:39 PM
2 Replies, 62 Views
sikhism Salok Sheikh Farid ji...
Yesterday 09:35 AM
0 Replies, 42 Views
sikhism In Punjab, three farmers...
Yesterday 05:36 AM
0 Replies, 45 Views
sikhism Supernatural Sikhs, what...
Yesterday 03:45 AM
19 Replies, 408 Views
sikhism Sukhmani Sahib Astpadi...
26-May-2012 22:57 PM
0 Replies, 46 Views
Do You Think You Are...
26-May-2012 09:59 AM
94 Replies, 8,258 Views
» Books You Should Read...
Powered by vBadvanced CMPS v3.2.2

All times are GMT +6.5. The time now is 06:43 AM.
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.5.2 Copyright © 2004-12, All Rights Reserved. Sikh Philosophy Network


Page generated in 0.48015 seconds with 30 queries