Modules & VBA :: Allow A User To Navigate To A Text File And Import It To A Database
Aug 19, 2013
We have a function that will allow a user to navigate to a text file and import it to a database. I've been asked to make it import ALL the text files from all sub-directories in the directory IF they've never been imported before (based on FileName and LastModifiedDate). I've set up a table to track what's getting imported (tbl_ImportHistory). I'm thinking what I need to do is use the previous coder's GetFileName function in a recursive loop removing the navigation request and adding the comparison and then, if it imports the file, the name and date need to be added to the tbl_ImportHistory table. But I'm completely unsure of how to do it.
I'm posting the GetFileName function below. I believe once I've got it modified the rest of the code can be left intact as it just parse's and loads whatever file is selected in the GetFileName function.
<code>
Function GetFileName() As String
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
fd.AllowMultiSelect = False
Dim vrtSelectedItem As Variant
[code]....
View Replies
ADVERTISEMENT
Jul 19, 2014
They are receiving e-mail with some data that they want to transfer to access database to track. The one think they can do is copy past, copy paste. That is a lot of data to copy and paste. The date looks like this format
Field1
Text1
Field2
Text2 (text2 can be more than 255 char)
Field3
Text3 (text3 can be more than 255 char)
Field4
Text4
Field1
Text1
Field2
Text2 (text2 can be more than 255 char)
Field3
Text3 (text3 can be more than 255 char)
Field4
Text4
and so on.. It can be 50 records
I am thinking they can copy this to the text file. Then the code form Access grabs the text file and imports to access table with format below.
Field1 Fied2 Field3 Field4
Text1 Text2 Text3 Text4
View 14 Replies
View Related
Apr 2, 2015
I'm trying to import a pipe delimited text file into a table. I can import the entire table using the following code, but I only get one column of data (the entire data set in one column). If possible I would like to import with the columns defined or if not possible use some code for a function similar to text to columns.
Code:
DoCmd.TransferText acImportDelim, , "tblTest", "C:Work2015PPVMasterData.txt"
View 4 Replies
View Related
Aug 2, 2013
I'm trying to import a text file with 273 fields into two tables. I've been able to do this with the code I found on an old thread and I'm now trying to accomplish everything with one step. The file I'm importing is tab delimited text file. With this current code I'm only able to populate the first record in the table and then I get error message. (Run-time error '3265') (Item cannot be found in the collection corresponding to the reqested name or ordinal).
Code:
Public Sub ImportTextFile()
' to use the ADODB.Recordset, be sure you have a reference set to ADO
Dim rst As ADODb.Recordset
Dim rst2 As ADODb.Recordset
Dim strFile As String
Dim strInput As String
Dim varSplit As Variant
Dim intCount As Integer
[code]...
View 4 Replies
View Related
Aug 22, 2014
I have a form which i use for a user to select an excel file they want to import and then click a cmd button to import the file into a table which works fine, however i want to append a date into a date field from an unbound txtbx before the file is imported so it will look something like;
id;date;excel info;excel info;excel info.
View 7 Replies
View Related
Jul 20, 2006
hello,
I would like to automate something presently done on a one-by-one basis. Here: a number of text files(containing data) are to be exported into an MS Excel file, with each text file to occupy a different worksheet. Presently, the idea is to use the Data/import external data/import data feature of MS Excel for importing the text files one-by-one into newly created worksheets(within the same workbook).
I would appreciate some advice on how to go about creating a useful MS Access application to achieve the above. I have checked the available Macros in MS Access, but I could not find one to suit my purpose. can anyone pls assist, on how I can get started?
Tokunbo
View 3 Replies
View Related
Nov 18, 2014
I am having a little difficulty with my importing in Access. Every time I import my text file, the lines will be jumbled. I have been reading up and I found this recordset code that seems to be what I need:
Code:
Dim strLine As String
Dim intLineNum As Integer
Dim MyDB As DAO.Database
Dim rst As DAO.Recordset
Open "C:TestTest.txt" For Input As #1
Set MyDB = CurrentDb
Set rst = MyDB.OpenRecordset("tblResults", dbOpenDynaset)
CurrentDb.Execute "DELETE * FROM tblResults", dbFailOnError 'Clear tblResults
[code]....
Basically, this code will extract data from the text file as long as it fulfills the Mid$ criteria. Here's where my problem comes. Each line in my text file is of different lengths and I have to capture the entire line.
I think using the Left$ function would work, but I don't know how to determine the character count such that the entire line of text would be inserted into the table.
Another difference between what I need and the code above is that, I am required to store each line into each row of my table, meaning
Line 1 is placed in Row 1 Column 1
Line 2 is placed in Row 2 Column 1
Line 3 is placed in Row 3 Column 1
.
.
.
Line X is placed in Row X Column 1.
View 14 Replies
View Related
Jan 30, 2006
hello everyone, i really need some detailed help as the deadline is approaching and I need to find a solution for this. Any help would be greatly appreciated
I currently have a batch file that ftps a text file from a Red Hat Linux Server to my W2k C:. I would like to make another command in the batch file that imports this text file into an existing access table. I would like the text file to repopulate the table everytime it is imported. I do not want the data added on to the existing data in the table.
Thank you for your time and insight.!!!:)
View 3 Replies
View Related
Dec 17, 2004
Hi
I have a log file that records an action in following format.
50144021 12-17-2004 21:00:44 Mail Sent Subject: Test file TO: bert@xxxxxx.com
I want my database to look into this file and return the date/time of the last send in the log to match up with a record in one of my tables that has following fields: "email","last sent", "subject". ( The match will be done on the email address)
I can therefore look at each record and identify when each email address was last sent the file
Any help would be much appreciated
Thanks
Mat
View 3 Replies
View Related
Sep 5, 2007
Hi all. Another question that i hope ya'll can answer.
I'm trying to take a comma divided text file and import the raw data from there into one Access table to allow for various data manipulations with the end result being a very nice printable report. Unfortunately, I can only get the data in a plain text file, and not a CSV file.
What I'm looking for is a method to where I can import one or many of these text files into a database at one time via a fairly automatic process (pressing a button to load all the text files in a given directory would work), and have the data filtered according to the pre-defined variables in the text file itself (which could just be pre-entered into the database as a template). How would I go about doing this?
p.s. If anyone wants to see an Excel file of a manual data sort to see what i'm talking about, please e-mail me and I'll send it off.
p.p.s. Thanks for any help you can give me
raw text file data (there's more, but this will suffice as an example):
price,volRemaining,typeID,range,orderID,volEntered ,minVolume,bid,issued,duration,stationID,regionID, solarSystemID,jumps,
4500000.0,16.0,25619,32767,512583166,16,1,False,20 07-09-04,7,60006655,10000043,30003562,12,
5010707.0,3.0,25619,32767,511108734,3,1,False,2007 -09-03,30,60006658,10000043,30003563,12,
5523022.0,2.0,25619,32767,512004088,2,1,False,2007 -09-04,14,60008494,10000043,30002187,2,
5010000.0,17.0,25619,5,512177386,19,1,True,2007-09-04,7,60008950,10000043,30002187,2,
View 11 Replies
View Related
Oct 18, 2014
How to read data in file (attached) and import data by reading certain amount of characters in a line like A02 and read 30 to 40 characters which has the Name of a passenger and may 20th to 25 has the name of an Airline. Import these data into a table with pre-assigned columns.
View 11 Replies
View Related
Jul 19, 2005
Hi, I'm trying to import a text file (just for a test at the moment) with the fields seperated by |'s.
The table I'm trying to import to has the fields -
ID, First Name, Last Name, Gender.
The ID is an autonumber though so what can I put there in the text file because I'm getting an error? :confused:
View 3 Replies
View Related
Feb 8, 2007
Hi,
I'm importing the contents of lots of text files using a combination of a loop and DoCmd.TransferText.
This works fine and I can get the contents of several hundred files in a few seconds. The files are called 1.dbb, 2.dbb... and each has an associated image file, 1.bmp, 2.bmp... etc. After the import I move the files to a new folder.
I need to create a link to the bmp file but this information is not included in the text file so I need to rely on a field which contains the file name.
How can I populate a field at import time to include the name of the imported file?
Anyone give me a clue please.
Regards,
Bernard D
View 4 Replies
View Related
Sep 15, 2004
I am importing a text file into Access97 using fixed width with import specifications that specify NO to indexing. However, when I run the Macro, it automatically indexes the first field (which is a long integer).
Why? How do I import the text file without having the index automatically added?
View 2 Replies
View Related
Oct 23, 2014
I am trying to complete a macro that starts with importing of a text file. However, when I go to complete the steps in the macro, I do not see the specs for the import file that i created. There is a dropdown with a few specs for me to choose from in the box titled "Specification Name" when I am completing the action titled ImportExport Text. However, none of those specs are the right ones.
When I go to "Saved Imports" I can plainly see the import that I am interested in. So is a Saved Import different than a spec? If so, what steps do I need to do to create the spec?
View 1 Replies
View Related
Sep 20, 2006
Hi all, I'm trying to get the following done:
I have code which import Excel files into my database with the "DoCmd.TransferSpreadsheet". which works great.
But I'm now splitting the database and I want to have the Excel files which a user selects in his frontend database, imported in my backend database. I don't see the possibility in the TransferSpreadsheet as this is set to the CurrentDb.
My temporary solution is to import in the frontend and CopyObject to the Backend, but does anyone have a direct solution?
Thanks, Rob
View 1 Replies
View Related
Nov 29, 2004
I have a secure MS Access database, where users by default can only read data, but not write. How can I prevent them from importing or linking files, or inserting objects? I don't want to use any passwords in my database, since it's used inside the application. Thank you.
View 1 Replies
View Related
Apr 7, 2015
I am trying to import a non-delimited text file into access, but where there is a strict hierarchy to the records, i.e.
NAME:
AGE:
DOB:
etc. etc.
The field names are constant throughout the document but the pages are of variable length depending on what is in the fields.
View 1 Replies
View Related
Apr 30, 2005
I want to import data in access or excel from snapshot file- *.snp. Can I?
10x
View 6 Replies
View Related
Apr 12, 2012
I have created a database with approximately 30 columns, 1st column being a primary key. At the end of the database there are 5 columns. We will call them VWXYZ.
One of my users wants to be able to update VWXYZ via importing an Excel document to the existing table. He does NOT want fields 1-25 updated. He is editing his Excel document to only include the primary key and then VWXYZ with the same exact column names. When he imports, it sets 2-25 to blank and updates VWXYZ to the updated information.
How can he import an Excel document that only updates VWXYZ?
View 3 Replies
View Related
Mar 17, 2015
I am new to Access and I am trying to make a Database. However, I have an attachment with each record and I would like to know if there is a way of making a button/link that will allow the user to navigate from each record to its respective attachment.
View 6 Replies
View Related
Jul 7, 2005
hello once again,
I need to import a text file into an existing table in Access. The text file has been imported once and is working well and everything. However, since I had to change some of the datatypes to be able to query the table correctly, I now cannot import the text file anymore unless I change the datatype of the table itself. Since someone other than I will be doing the imports from here on out, changing the datatypes everytime is out of the question. I was looking at the TransferText event, but I didn't seem to see anything about converting data types. I can think of two options, and neither are probably possible:
1. import using the wizard. Since I didn't see anything related to the types of data, I don't think this will work...
2.import using TransferText. This doesn't seem to give me any opportunity to change the datatypes either. Is there anyway to programmatically change datatypes, or is there possibly an easier way that I'm overlooking??
thanks in advance,
*j
View 4 Replies
View Related
Feb 11, 2015
simple table 6 columns
startdate
enddate
custacct
salescost
salesprice
salesqty
the txt file is set up so that there is a header record, 4,999 lines of data, then the same header record, then 4,999 lines of data, then a header record etc etc. for as many lines as is in the download. This is a download TXT file from a Microsoft Axapta ERP system.
I have my table all set up and during the import I want the header records to be dropped. I tried in the validation section for startdate {Not "startdate"} but that did not work. Is there some simple way to ensure the header records are dropped?
View 2 Replies
View Related
Oct 8, 2013
I upgraded to Access-2010 and the Text File Import function will not recognize dates in the format YYYY-MM-DD. The import dialogue sees enough to recognize the field as a date, but then every date encountered is written to the Import-Errors table. This is true whether the file has a .txt or .csv extension. The actual file format is .csv.
View 6 Replies
View Related
Sep 17, 2013
I'd like to import an excel file but the data begin from cell "A10", above there is a "privacy text".Is it possibile import or link the excel data in an access table directly from the cell A10?
View 1 Replies
View Related
Feb 2, 2015
I'm trying import some information from excel file into Access Database but I need have imported information formatted in specific way.
Import file is looking like:
City - Week / 1 / 2 / 3 / 4 / 5 / 6 / 7 / 8
London / 3 / 1 / 4 / 5/ 5/ 9/ 1/ 3/ 4
Chicago / 2 / 1 / 4/ 8/ 3/ 3/ 2/ 1 / 5
Paris / 9 / 4/ 1/ 7/ 8/ 9 / 1 / 1 / 2
And i need table in Access looking more like
City / Week / Value
London / 1 / 3
London / 2 / 1
London / 3/ 4
London / 4 / 5
and so on for each city.Is there any option that this can be done within DB or It would need be some kind of macro to transfer this into other format?
View 1 Replies
View Related