Modules & VBA :: Loop Through Files And Then Compare With Files In Database Table
Nov 11, 2013
I have to write a code for my database,i have folder with files "pending Review" and a table with column "tblExcelLocation". when i run my database all the files from pending review folder goes to "tblExcelLocation" on a click of button.But,if the files already exists it should not insert those files and insert the rest.For this i tried to write a code but i think i m unable to do that .
Code:
Loop through files in folder
folderspec = "O:QA FilesQC ReportingPending Review"
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.GetFolder(folderspec)
Set fc = f.files
Basically what I am trying to accomplish is uploading multiples file automatically into server. The code I am trying to use works great if the user wants to upload a single file manually because the code prompts you to choose the file and I am wondering if there is a way to tweak the code. here is the code I am using
Code: Private Sub Form_Load() Dim objFTP As FTP Dim strfile As String
i want to browse the files from a form and then store hem to the database.i have the following code, i can show the file path to the text box but i don't know how to store the file or how to upload the file to the database.
Dim f As Object Dim strFile As String Dim strFolder As String Dim varItem As Variant
Is it possible to edit the recent files of a access database?
We have a main database (version control database) from where you can open a database which is located on a network drive.
By selecting the datbase you need from a dropdown menu, access will check which version you have locally. If there is an updated version available on the network it will download this updated version, overwriting the old one. The 'main' database is then closed and the local version of the database you needed is opened.
The problem is that this local database is mentioned in the recent files history so people are able to bypass using the main database.
In Excel you can clear the recent files with application. Recent Files setting the maximum to 0 and back to original again. In Access you do not have this option.
Where I would be able to find this option. Ideally I'd like to only take out a specific databasename from the recent files, rather then resetting the full list.
I have files that have extension of TSV which are text files but viewable in exel. I figured out a way for the user to click on a button in Access which does the following
1. Run Macro in Excel: The macro prompts the user to select the TSV file. After selection, macro opens the employee.tsv file in the excel (with excel being invisible) and saves it as employee.xls
Code: Sub SaveTSVtoXLS() Dim myPath As String Dim myString As Variant Application.DisplayAlerts = False With Application.FileDialog(msoFileDialogOpen)
[Code] .....
2. Imports the Excel file (employee.xls) into two tables: tblEmployee and tblDepartment using the following codes.
My database generates forms with a unique number displayed as a barcode. The paper forms are completed by employees and then scanned into a folder on the network in .TIFF format. I have seen other databases that can somehow pick up files like this and update the forms status in the database (i.e., Completed), assign a completion date and create a link to the file (a PDF actually).
I would really like my database to be able to do this but dont even know where to start. How do I get the file names for the .TIFF files to match the barcodes during the scanning process? How do I get Access to check a Completed field for each document in the folder? How do I get Access to put a link to the file in a field in the table?
I have a folder that gets updated with a few new xml files every day. I need to import the data in these files into a table. The names of the files to import is in a field (FName) in a table (tblFiles).
Code to rename photos (Access 2010). The new name (full path) is listed on a table (although I would love to accomplish the task from the list query that I later used to generate the table). There is one field in the table (or query) called OldPath and one field called NewPath. The table name is RenPaths. Both paths are located in the same drive. I want to rename the file in a new folder. I created the new folder which is contained in the NewPath.
I was trying to accomplish this using the Name function
Name OldPath as NewPath
Here is the full code:
Private Sub Command0_Click() Dim rs As DAO.Recordset Dim db As DAO.Database Dim OldPath As String Dim NewPath As String OldPath = "Select OldPath From RenPaths"
[Code] ....
Here is an example of the paths in my table:
Old Path is - C:UserskcrespoDocumentsFulcrum to MACPFulcrum_Export_a97dee97-ba92-455e-9d5c-3b35617ad357SAA Inspection Form367e14e0-439b-4a50-99e1-9154bcc9e3f7.jpg
New Path is - C:UserskcrespoDocumentsFulcrum to MACPFulcrum_Export_a97dee97-ba92-455e-9d5c-3b35617ad357SAA Inspection FormimageswwMH51856_A3f7.jpg
Im getting an error: Run time error '53': File not found
I checked the OldPath and everything is correct so if the code is working correctly it should have found the file.
I am trying to write a VBA Module that will look in a directory for Excel files with a specific file prefix, and then import specified cells into a temp table. Once it processes the first file, it copies the file to another folder, and then kills the file. However, when I run my current code, it goes through the loop the first time, but fails on the second attempt, because it is still looking for the first file it came across even though it has been moved. The code is pasted below:
Sub Count()
Dim xlwrksht As Excel.Worksheet Dim xlWrkBk As Excel.Workbook Dim nIndex As Integer Dim strMvPath As String Dim mvPath As String Dim strFile As String
I have a process that reads a list of files sequentially and then processes them .... As each file is processed, its name (strfile) gets written to a Table (Vault.[Processed_file])
I want to verify if the file exists in the table prior to processing it - if it exists, I won't process it again ...
some code I've come up to in order to import multiple excel files each of them with a different number of worksheets into an access table. The procedure is called from an Access database. The problem I have with the code is that when it encounters a workbook with only one worksheets (e.g. Sheet 1) it gives the error that "Sheet 2$" is not a valid name. When geting to a workbook with 2 sheets it says that "Sheet 3$" is not a valid name and so on and so forth. Is there a way to "check" the number of sheets in the workbooks and when it has only one sheet to transfer it and go to the next file?
Below is the code:
Code: Sub ImportExcelFiles() Dim strFile As String 'Filename's Dim strFileList() As String ' File Array Dim intFile As Integer 'Number of files Dim filename As String Dim path As String DoCmd.SetWarnings False path = "D:Tranzactii"
Every hour a zip file is created in an FTP folder. The zip file contains an .mdb access database file with any changes to the data since the last hours file.
What is the best method to get access to connect to the content of the zip files and pick up the changes to the data?
I am trying to concatinate string in a loop to generate a dynamic SQL to compare 2 tables. But I am not getting the result I want
Code: Set rs = CurrentDb.OpenRecordset("r1") Set rs2 = CurrentDb.OpenRecordset("r1_old") columnCount = CurrentDb.TableDefs("r1").Fields.count strSQL = "" For I = 0 To columnCount
[Code] .....
I am trying to achieve something that reads like the following
r1.Field(0) = r2.Field(0) AND r1.Field(1) = r2.Field(1) AND r1.Field(2) = r2.Field(2) AND .....
hello, im actually trying do design a database with attached word files, ie the persons information and his attached cvs i never done that before and im confused, should i attach all the cvs(words documents) to the database ie can i create a field which is a word document or i should put all the cvs in a folder outside the DB and put a link to them in the table taking into consideration that it s gonna be a big database, and if so can the user attach a file to the database using a button ie in the forms thanks in advance
I have a database on a shared network drive. All users except the manager have only read access to the file/directory. However, if the manager tries to open the file while other users have access open, it only allows him to read it as read only. If they close the database, then he can open it with read-write. Does access use another mechanism other than ldb files for locking?The weird thing is that it seems to be locking correctly. If the manager tries to open the file while someone has it open, it's read-only.
We have a client who has managed to muck up their Access database by means of having two users on two computers attempting to use and modify it at the same time, and the primary (actually, the only) location for the database is on Dropbox.
What seems to have happened is that Dropbox detected a conflict, with two different versions of the same file, and resolved this by creating two separate files. How long this went on before the client noticed that they were entering data into two separate files, I can't say.
Their client list is 28,000 someodd people long. What I need to know is if there's a process for merging the two files together, without creating 28,000 duplicate entries. This is being run on Access 2002.
And yes I now that's the title of a Knowledge base article, I stole it because it put into words what I can only say in expletives right now.
Basically, well it's all a bit odd. I got users on the network who, until yesterday, could access some networked databases. Other files from the same source are ok, just Access files. Today the moment they click (and I mean a single-click) on the icon to open the database...explorer hangs. You can't open the database from within MS Access either, that hangs too. But you CAN open them up and use them if you can get them copied locally. Oh yeah, some people (in the same room, on the same VLAN) can access the database, but can't perform any tasks within it. Databases are a mix of 97 and 2000. And to make matters worse, it's happening on another server.
I know you're gonna shout virus, but that looks to be a non-starter since I know of no such virus which would affect ONLY Access files and do it on a single click, and secondly The systems check out fine with both Sophos (and our good luck charm AVG) run against them.
Holy Moley! Has anyone ever come accross such a palarva?
I'm trying to write a simple little database. At one point on a form, I'm trying to merge all the pdf files in a particular folder. (I'm using the pdftke.exe program and there will be multiple pdf files)
It all works perfectly if I call it as below, with the actual paths already hard coded. It combines all the pdf files and renames it to the "merged filename.pdf" correctly
Dim stAppName1 As String stAppName1 = "C:a folder namepdftk.exe C:another folder nameprints*.pdf cat output C:folder where merged file will bemerged filename.pdf" Call Shell(stAppName1, 1)
However, I'm trying to have it work with the middle portion (the folder where all the pdf files are) being created on the fly so to speak.
The middle portion/path I have stored from a previous form and it's stored in a table.
So I'm trying the below, but doesn't seem to work.
Dim stAppName1 As String Dim combine_files As String combine_files = (this pulls a path from a stored field on the open form) + "" + CStr("*.pdf")
stAppName1 = "C:a folder namepdftk.exe (combine_files) cat output C:folder where merged file will bemerged filename.pdf" Call Shell(stAppName1, 1)
With the code above, it doesn't seem to do anything.
I added to my database a button to ouput the data to PDF. It works as it should. We do print out the letters in paper and put a copy in the folder from the client (connected with the ID nr). From time to time we need to attach a PDF document to the letter and combine it. My question is now if it is possible to have some code to the button that when it finish the output to PDF it will combine all the PDF files that are in the folder and put it in a second folder. After that, I need to put the combined PDF in another folder.
I have 200 excel files in folder C:UsersLburchDocumentsHistoric DataTedan Data in Excel Worksheets - CopyAAA - Copy.The files only have one worksheet and the column format are the same. Worsheet name is different for every file though.Headings in first row.write a macro to import into 1 Access table so I don't have to do it manually.
My report has tens of pages and I need to save each page as separate file with ID as filename. PDF prints with ID but all in one file. I use this code.
Option Compare Database Private Sub tisk() Dim cesta As String Dim kod As String Dim Sql As String Dim rs As Recordset