Darren D
darren at activebilling.com.au
Thu Aug 7 02:10:39 CDT 2008
Howdy Thanks for the reply- I kinda did that by use of a UI Code below - maybe you can spot an error in it I have a number of unbound text boxes on the form Me.txtFolder - Usually populated with a path = EG N:\test\Myfolder Me.txtMergedFileName - The merged file name (Defaults to 'MergedFile') Me.cmbFileTypes - What file types to go looking for (Defaults to *.XML) Me.txtCounterLimit - At what file count to start a new merged fie Me.cmbSuffix - Asks the user what suffix to put at the end of any merges folder (options are 'XML' and 'txt') '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ '<Code Start> Private Sub ps_CopyBlocks() On Error Resume Next Dim lngCounter As Long Dim lngFileCounter As Long Dim strFile As String Dim strMergeFile As String Dim strTemp strMergeFile = Me.txtFolder & "\" & Me.txtMergedFileName & "_00." & Me.cmbSuffix Open strMergeFile For Output As #1 strFile = Dir$(Me.txtFolder & "\*." & Me.cmbFileTypes) Do Open strFile For Input As #2 While Not EOF(2) Line Input #2, strTemp Print #1, strTemp Wend Close #2 lngCounter = lngCounter + 1 If lngCounter = Me.txtCounterLimit Then lngFileCounter = lngFileCounter + 1 lngCounter = 0 Close #1 strMergeFile = Me.txtFolder & "\" & Me.txtMergedFileName & "_" & Format(lngFileCounter, "00" & "." & Me.cmbSuffix) Open strMergeFile For Output As #1 End If strFile = Dir$ '<--me thinks the error maybe here Loop Until strFile = "" Close #1 End Sub '</Code Start>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -----Original Message----- From: accessd-bounces at databaseadvisors.com [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan Sent: Thursday, 7 August 2008 4:29 PM To: Access Developers discussion and problem solving Subject: Re: [AccessD] A2003: Merging top 50 files then next 50 files andsoon Open an Immediate window in the any Access application (hit Ctrl+G) Enter "? CurDir" You will see that the default directory for an Access Application is "My Documents". (unless you change "Default database folder:" under "Tools-Options-General" You can do one of two things: 1. Initally use CHDIR to change the directory 2. Put the path in front of the relevant code. I prefer to use the second method. If you want to run in the directory that the Access application is in, make the following changes: Change: strMergeFile = "MergeFile00.txt" To: strMergeFile = CurrentProject.Path & "\MergeFile00.txt" Change: strFile = Dir$("*.xml") To: strFile = "Dir$(Currentproject.Path & "\*.xml") Change: strMergeFile = "MergeFile" & Format(lngFileCounter, "00" & ".txt") To: strMergeFile = CurrentProject.Path & "\MergeFile" & Format(lngFileCounter, "00" & ".txt") Cheers, Stuart On 7 Aug 2008 at 14:51, Darren D wrote: > Hi Stuart > > You are a legend this is way cool > > Now, I have a strange issue with this. When I drop say 20 or 30 xml files in the > My Documents folder and run the dB, from My Documents as well, it runs lovely > > Drop those same XML into another folder and the dB into that same folder it > seems to get stuck in some monstrous loop that never ends and the new > destination merge file just grows and grows and does not stop until I do a 3 > finger salute > > Any reason why it would work in the My Documents folder and not in another > folder? > > Many thanks > > Darren > -----Original Message----- > From: accessd-bounces at databaseadvisors.com > [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Stuart McLachlan > Sent: Wednesday, 6 August 2008 8:06 AM > To: Access Developers discussion and problem solving > Subject: Re: [AccessD] A2003: Merging top 50 files then next 50 files andsoon > > Yep, another ommission on my part ( I did warn you <g>) > > You need to do a > Close #1 > after > Loop Until strFile = "" > to close the last merge file. > > It's not using any objects, so there is no need to do anything else. > > > > On 5 Aug 2008 at 15:22, Darren D wrote: > > > > > Stuart - Fantastic > > > > Works an absolute treat many many thanks - you are a legend > > > > What is the standard code bits to get it to release the file whilst the dB is > > open? I also assume there are objects to be closed or set to nothing - yes? > > > > Code working nicely below > > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Private Sub ps_CopyBlocks() > > > > On Error Resume Next > > > > Dim lngCounter As Long > > Dim lngFileCounter As Long > > Dim strFile As String > > Dim strMergeFile As String > > > > strMergeFile = "MergeFile00.txt" > > Open strMergeFile For Output As #1 > > strFile = Dir$("*.xml") > > Do > > Open strFile For Input As #2 > > While Not EOF(2) > > Line Input #2, strtemp > > Print #1, strtemp > > Wend > > Close #2 > > lngCounter = lngCounter + 1 > > If lngCounter = 10 Then > > lngFileCounter = lngFileCounter + 1 > > lngCounter = 0 > > Close #1 > > strMergeFile = "MergeFile" & Format(lngFileCounter, "00" & ".txt") > > Open strMergeFile For Output As #1 > > End If > > strFile = Dir$ > > Loop Until strFile = "" > > > > End Sub > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > > -- > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com -- Stuart Mclachlan -- AccessD mailing list AccessD at databaseadvisors.com http://databaseadvisors.com/mailman/listinfo/accessd Website: http://www.databaseadvisors.com