-
WSRNCIENG
AskWoody LoungerGood Morning,
I appreciate all your efforts very much and wish I had your talent and knowledge.
I’ve tried everything under the sun to get either of your options to process when the path has a space in it and it doesn’t. It’s shame because it works beautifully when the path doesn’t include a space in the path.
The paths that I’m using for both options is a network path (see examples below).
\myCompanyMyPaththisonehas spaces — doesn’t work returns msg: “No files matching search pattern found!, exiting”
\myCompanyMyPaththisone_uses_underscores — works perfectly.
If you have any other suggestions, I’m open but I totally understand you have other projects to work on and again, appreciate all your efforts. My only other option for now, is to continue to run the batch file and manually load to Access.
Thanks so much for your help and guidance.
-
WSRNCIENG
AskWoody LoungerI am speechless….I love this. Thank you so much.
There are 2 minor problems–
1. If the path I’m searching has a space in it I get “no files matching search pattern”. If I put the Open/Close Quotes around the path (Dir1Data Sources) then I get “run time error 52” bad file name..
2. It doesn’t search sub folders
For #1, I don’t have a clue how to handle the space within the path.
For #2 I will see what I can do to modify the sub folder issue.Again, thank you so much.
-
WSRNCIENG
AskWoody LoungerRetired,
I am currently just running the batch file which creates a text file. I manually open the newly created text file then copy and paste into my table. Yes very clunky but it’s the only way I know how to do it at this point. The one thing I want to add, that isn’t included in the batch process, is to capture the path and file size. I can’t thank you enough for all your help, it’s greatly appreciated.
Batch File:
Code:@ECHO OFF CLS ECHO. ECHO EXTRACT FILE NAMES JOB… ECHO. SET /P confirmRun=ARE YOU SURE TO CONTINUE(Y/N)?: IF “%confirmRun%”==”” GOTO Error IF “%confirmRun%”==”N” GOTO Error ECHO. SET /P sourcePath=KEY IN THE SOURCE PATH: ECHO. SET /P destPath=KEY IN THE DESTINATION PATH: ECHO. SET /P outPutFileName=KEY IN THE OUTPUT FILENAME(ex: FileName.txt): ECHO. ECHO CHECKING FOR DIRECTORIES… ECHO. IF exist “%sourcePath%” (ECHO %sourcePath% FOUND) ELSE ( ECHO %sourcePath% NOT FOUND GOTO Error ) ECHO. IF exist “%destPath%” (ECHO %destPath% FOUND ALREADY) ELSE ( mkdir “%destPath%” ECHO %destPath% CREATED ) SET “outputFileFullName=%destPath%%outPutFileName%” ECHO. ECHO COMPLETED CHECKING DIRECTORIES!!! ECHO. ECHO PREPARING RESULT… for /b /s “%sourcePath%” %%i in (*.*) do @echo %%~nxi >>”%outputFileFullName%” ECHO CHECK RESULT FILE HERE… ECHO %outputFileFullName% ECHO. ECHO JOB COMPLETED SUCCESSFULLY… ECHO. ECHO. SET /P confirmRun=JOB ENDS HIT ENTER TO EXIT: EXIT GOTO End :Error ECHO. ECHO Job Ends! Bye bye!! ECHO. ECHO. SET /P confirmRun=JOB ENDS HIT ENTER TO EXIT: EXIT :End
-
WSRNCIENG
AskWoody LoungerRetired Geek —
Yes I use the file names in my db and your suggestion sounds great, however, there are a couple of hurdles to overcome, the path name will change each month, i.e. \mypathProject2MM_MMMYY and I’m not very good with coding Array’s. I didn’t think anyone would want to assist with that so I didn’t ask. But would certainly love explore that option and give it a try.
Thanks.
-
WSRNCIENG
AskWoody LoungerDecember 2, 2015 at 4:23 pm in reply to: Access 2010: Compare and copy files to new directory #1540162Thank you sooooo much, it work beautifully!!!!
-
WSRNCIENG
AskWoody LoungerDecember 2, 2015 at 12:52 pm in reply to: Access 2010: Compare and copy files to new directory #1540136You are correct, the list of file names is in an Access table, tbl_FileNameList_v18 and field name is v18_FileName.
-
WSRNCIENG
AskWoody LoungerThis report is required by the state and must include daily activities and must be in Excel or cvs format. For the most part, I would prefer a crosstab query w/in Access but over a 5 month period and capturing daily data, I think the best approach is export to Excel (the entire Project is in Access).
The spreadsheet would have the following:
Row Heading=User name (i.e. Row 1)
Column Heading = Date (i.e. Column A)
Cells w/in Column will be the counts (i.e. Row2 columnA)I’m not sure how to get the data out of Access and automatically update the fields at correct intersection with the correct username and correct.
-
WSRNCIENG
AskWoody LoungerFirst, I apologize for the name error.
Secondly, I finally have the problem resolved. I accomplished this by the following:
I created a Public Function
Public strPVDID As String
Public Function GetPVDId() As String
GetPVDId = strPVDID
End FunctionIn the query for the report(s) I pass strPVDID as a parameter.
strPVDID changes as the code goes through the loop
AND–
Changed:str_ToFaxName = Me.txt_To
To:strPVDID = MyRS.Fields(“txt_HEDIS_Fax_To”).ValueChanged:str_ToFaxName & “_MRR.pdf”
To: str_MyFilename = strPVDID & “_HEDIS_MRR.pdf”Thanks for all the help everyone.
-
WSRNCIENG
AskWoody LoungerThanks R4. I’ve made the change as he suggested. The str_ToFaxName is the only variable I need from the recordset. The path is where the report resides. The report is named using the str_ToFaxName and it’s recordset has a parameter based on the form’s text field str_ToFaxName and is a pdf file. So, the path is static but the report name is not. Should I do something different there?
Since I made the change as suggested, the code does loop correctly now but now I get the same report. I’m so confused
-
WSRNCIENG
AskWoody LoungerJeremy,
Let me be more clarify.
I have a bound form, recordset is qy_MYQRYName (generic for posting purposes). I would rather not use a form at all only adopted the form usage based on Microsoft Office’s code. I would prefer to simply use the qry as the recordset and code to loop through that. I simply don’t know how to make that happen and have tried several things. Again, I don’t get any errors and the code runs but only captures the first record. I would love some assistance with this if you could offer.Thanks so much for your time.
-
WSRNCIENG
AskWoody LoungerThanks RG, I will give this a try and update then.
-
WSRNCIENG
AskWoody LoungerI can’t thank you enough for the help. Thanks to your advice, I modified the code as you outlined and the entire process works as it should now.
Code:On Error GoTo Err_cmdOpenQuery_Click Dim MyDB As DAO.Database Dim qdef As DAO.QueryDef Dim i As Integer Dim strSQL As String Dim strSQLGroup As String Dim strWhere As String Dim strIN As String Dim flgSelectAll As Boolean Dim varItem As Variant Set MyDB = CurrentDb() strSQL = “SELECT ApVenTest.VenNumID, ApVenTest.VenName, ApTest.GrossAmt” & vbCrLf & _ “FROM ApTest INNER JOIN ApVenTest ON ApTest.VenNum=ApVenTest.VenNumID” strSQLGroup = “GROUP BY ApVenTest.VenNumID, ApVenTest.VenName, ApTest.GrossAmt” & vbCrLf & _ “HAVING (((Count(ApTest.GrossAmt)) > 1))” ‘Build the IN string by looping through the listbox For i = 0 To lstVenNum.ListCount – 1 If lstVenNum.Selected(i) Then If lstVenNum.Column(0, i) = “All” Then flgSelectAll = True End If strIN = strIN & “” & lstVenNum.Column(0, i) & “,” End If Next i ‘Create the WHERE string, and strip off the last comma of the IN string strWhere = ” WHERE [VenNumID] in (” & Left(strIN, Len(strIN) – 1) & “)” ‘If “All” was selected in the listbox, don’t add the WHERE condition If Not flgSelectAll Then strSQL = strSQL & strWhere & strSQLGroup End If MyDB.QueryDefs.Delete “qry_Vendor_rst” Set qdef = MyDB.CreateQueryDef(“qry_Vendor_rst”, strSQL) ‘Open the query, built using the IN clause to set the criteria ‘DoCmd.OpenQuery “qry_Vendor_rst”, acViewNormal Me.Requery ‘Clear listbox selection after running query For Each varItem In Me.lstVenNum.ItemsSelected Me.lstVenNum.Selected(varItem) = False Next varItem Exit_cmdOpenQuery_Click: Exit Sub Err_cmdOpenQuery_Click: If Err.Number = 5 Then MsgBox “You must make a selection(s) from the list”, , “Selection Required !” Resume Exit_cmdOpenQuery_Click Else ‘Write out the error and exit the sub MsgBox Err.Description Resume Exit_cmdOpenQuery_Click End If
-
WSRNCIENG
AskWoody LoungerI really appreciate your help. I added the debug.print and breakpoint. Below is the code from the immediate window.
Code:SELECT ApVenTest.VenNumID, ApVenTest.VenName, ApTest.GrossAmt FROM ApTest INNER JOIN ApVenTest ON ApTest.VenNum=ApVenTest.VenNumID GROUP BY ApVenTest.VenNumID, ApVenTest.VenName, ApTest.GrossAmt HAVING (((Count(ApTest.GrossAmt))>1)) WHERE [VenNumID] in (10547)
-
WSRNCIENG
AskWoody LoungerI’m going to post my entire code so someone can perhaps show me the error of my ways.
Code:On Error GoTo Err_cmdOpenQuery_Click Dim MyDB As DAO.Database Dim qdef As DAO.QueryDef Dim i As Integer Dim strSQL As String Dim strWhere As String Dim strIN As String Dim flgSelectAll As Boolean Dim varItem As Variant Set MyDB = CurrentDb() strSQL = “SELECT ApVenTest.VenNumID, ApVenTest.VenName, Abs([GrossAmt]) AS GrsAmt ” & _ “FROM ApTest INNER JOIN ApVenTest ON ApTest.VenNum = ApVenTest.VenNumID ” & _ “GROUP BY ApVenTest.VenNumID, ApVenTest.VenName, Abs([GrossAmt]) ” & _ “HAVING (Count(ApTest.GrossAmt)>1)” ‘Build the IN string by looping through the listbox For i = 0 To lstVenNum.ListCount – 1 If lstVenNum.Selected(i) Then If lstVenNum.Column(0, i) = “All” Then flgSelectAll = True End If strIN = strIN & “” & lstVenNum.Column(0, i) & “,” End If Next i ‘Create the WHERE string, and strip off the last comma of the IN string strWhere = ” WHERE [VenNumID] in (” & Left(strIN, Len(strIN) – 1) & “)” ‘If “All” was selected in the listbox, don’t add the WHERE condition If Not flgSelectAll Then strSQL = strSQL & strWhere End If MyDB.QueryDefs.Delete “qry_Vendor_rst” Set qdef = MyDB.CreateQueryDef(“qry_Vendor_rst”, strSQL) ‘Open the query, built using the IN clause to set the criteria DoCmd.OpenQuery “qry_Vendor_rst”, acViewNormal Me.Requery ‘Clear listbox selection after running query For Each varItem In Me.lstVenNum.ItemsSelected Me.lstVenNum.Selected(varItem) = False Next varItem Exit_cmdOpenQuery_Click: Exit Sub Err_cmdOpenQuery_Click: If Err.Number = 5 Then MsgBox “You must make a selection(s) from the list”, , “Selection Required !” Resume Exit_cmdOpenQuery_Click Else ‘Write out the error and exit the sub MsgBox Err.Description Resume Exit_cmdOpenQuery_Click End If End Sub Private Sub cmdClose_Click() On Error GoTo Err_cmdClose_Click DoCmd.Close Exit_cmdClose_Click: Exit Sub Err_cmdClose_Click: MsgBox Err.Description Resume Exit_cmdClose_Click
-
WSRNCIENG
AskWoody LoungerThanks for the quick Response, however, I’ve removed the &; and still get the message. I’m open to any other ideas.
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Windows 11 Windows Updater question
by
Tex265
1 hour, 9 minutes ago -
Key, Key, my kingdom for a Key!
by
RetiredGeek
5 hours, 46 minutes ago -
Registry Patches for Windows 10
by
Drcard:))
10 hours, 16 minutes ago -
Cannot get line length to NOT wrap in Outlining in Word 365
by
CWBillow
10 hours, 29 minutes ago -
DDU (Display Driver Uninstaller) updates
by
Alex5723
3 hours, 39 minutes ago -
Align objects on a OneNote page
by
CWBillow
15 hours, 44 minutes ago -
OneNote Send To button?
by
CWBillow
16 hours, 28 minutes ago -
WU help needed with “Some settings are managed by your organization”
by
Peobody
1 day, 1 hour ago -
No Newsletters since 27 January
by
rog7
20 hours, 58 minutes ago -
Linux Mint Debian Edition 7 gets OEM support, death of Ubuntu-based Mint ?
by
Alex5723
1 hour, 34 minutes ago -
Windows Update “Areca Technology Corporation – System – 6.20.0.41”
by
Bruce
14 minutes ago -
Google One Storage Questions
by
LHiggins
1 hour, 35 minutes ago -
Button Missing for Automatic Apps Updates
by
pmcjr6142
55 minutes ago -
Ancient SSD thinks it’s new
by
WSila
6 hours, 10 minutes ago -
Washington State lab testing provider exposed health data of 1.6 million people
by
Nibbled To Death By Ducks
1 day, 15 hours ago -
WinRE KB5057589 fake out
by
Susan Bradley
1 day, 9 hours ago -
The April 2025 Windows RE update might show as unsuccessful in Windows Update
by
Susan Bradley
23 hours, 48 minutes ago -
Firefox 137
by
Charlie
2 hours, 34 minutes ago -
Whisky, a popular Wine frontend for Mac gamers, is no more
by
Alex5723
2 days, 4 hours ago -
Windows 11 Insider Preview build 26120.3863 (24H2) released to BETA
by
joep517
2 days, 4 hours ago -
Windows 11 Insider Preview build 26200.5551 released to DEV
by
joep517
2 days, 4 hours ago -
New Windows 11 PC setup — can I start over in the middle to set up a local id?
by
ctRanger
1 day ago -
Windows 11 Insider Preview Build 26100.3902 (24H2) released to Release Preview
by
joep517
2 days, 7 hours ago -
Oracle kinda-sorta tells customers it was pwned
by
Nibbled To Death By Ducks
2 days, 14 hours ago -
Global data centers (AI) are driving a big increase in electricity demand
by
Kathy Stevens
3 days ago -
Office apps read-only for family members
by
b
3 days, 2 hours ago -
Defunct domain for Microsoft account
by
CWBillow
2 days, 23 hours ago -
24H2??
by
CWBillow
1 day ago -
W11 23H2 April Updates threw ‘class not registered’
by
WindowsPersister
20 hours, 4 minutes ago -
Master patch listing for April 8th, 2025
by
Susan Bradley
1 day ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.