Modules & VBA :: Import A CSV

Dec 9, 2013

I'm trying to import a CSV. When I open the CSV, some of the values have decimal places (e.g. the dollar charge is $342.25). When the file is imported to a table, it shows up as $342.00. I import this file every month, and never have a problem. For some reason this month, the file is importing only the whole number.

View Replies


ADVERTISEMENT

Modules & VBA :: Import Csv Files And Rename Them After Import Into (imported) And (failed)

Jul 17, 2015

I have the following piece of code for importing the .csv files from a selected folder and then renaming them into 'imported & filename' if succesful and 'failed & filename' if import failes for whatever reason (bad formating, etc.).

The problem is that the first time it encounters a 'bad' file after another, instead of going again to the Error handler, the command

Code:
DoCmd.TransferText acImportDelim, , "Activitate", filename, True

gives me the default MS Access error, namely 2391. I would like it to go the the Error_handler again ang follow the course of actions and rename the files into 'failed' and 'imported'.

Here's the code:

Sub ImportActivitate()
Dim strFile As String 'Filename's
Dim strFileList() As String ' File Array
Dim intFile As Integer 'Number of files
Dim filename As String, sFullName As String, sFilename As String
DoCmd.SetWarnings False

[code]....

Also, how can I make the routine stop cycling through the files after I renamed them all?

View 3 Replies View Related

Modules & VBA :: Import Type Mismatch

Feb 24, 2014

I created some VBA imports from a saved Excel file. When I run it on my computer, it works fine. When my coworkers run it, they get an error "Type mismatch." Some files seem to upload despite the error, but I'd like to figure out why it's happening, especially for cases where the data doesn't import. As a band-aid, I added a line in my error handler that says if the error = "Type mismatch." then just resume.

View 2 Replies View Related

Modules & VBA :: Import File With Dynamic Name

Jan 28, 2014

I have text files placed into a folder like AIN28_01012014_1355.txt

I need to import these but the files have the date and time added to the name which i cannot stop AIN28_ will always be the same is there a way to import the file just off AIN_*.txt or something like that

I was thinking i could use file copy and change the name but that needs to know the exact names doesn't it...

View 1 Replies View Related

Modules & VBA :: Import Data From Website

Aug 23, 2014

I want to import data from a webpage using VBA and then store the HTML contents in a table (well, actually just part of the contents in fact).

View 7 Replies View Related

Modules & VBA :: Import Excel Into Access

Jul 18, 2013

I'm trying to import an excel file that includes a column of Part Numbers that I am interested in. I am trying to import that excel file into an access table called 'TableForImport'. That table has a column called 'PartNumber'. Thing is it's not just one Excel file that I am uploading...although I am uploading one file at a time. So the column name for each excel file table is different but they all have one column for the Part Numbers that I am interested in.

My code won't allow me to import the excel file into table 'TableForImport' unless they have the same column name! They never will! How do I accomplish my task without editing the excel file information? Here is my code:

Code:

CurrentDb.Execute "CREATE TABLE TableForImport " _
& "(PartNumber CHAR);"
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel12Xml, "TableForImport", Me.ExcelInput, True

View 8 Replies View Related

Modules & VBA :: Import Word Form Data

Nov 26, 2013

I am using the follow code to import data from a Word form into my MS Access 2010 DB:

Code:
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tmpSIRs", dbOpenDynaset)
With rst
.AddNew

[code]...

On the Word Form, these two fields are drop-downs with three options: blank, No, and Yes. If the users leaves them blank, then Access ignores them--which is what I want. However, if the user says yes or no, Access puts a "-1" in the database. Both the Word form and Access field are text.

View 2 Replies View Related

Modules & VBA :: Import CSV Into Access - 2391 Error

Jan 16, 2015

I'm simply trying to import a csv file into Access regularly using this code

Code:

Sub Command0_Click()
'import from text file
DoCmd.TransferText acImportDelim, , "test", "M: estR.csv", "-1"
End Sub

The error I'm getting is attached in the word doc. What that weird symbol references..

View 1 Replies View Related

Modules & VBA :: Import All The Data In PDF Forms To The Table

Jul 11, 2013

I have a fill-in pdf form, with fields that match database table fields. My database is in SQL, but I use Access for the forms and reports.

The users will go on-site (and be offline), fill out the pdf forms a bunch of times and come back with a folder of them.

I am looking for a way to have a form where a user can choose a folder (maybe on an access form) and say "import PDFs" and then have all the data in the PDF forms import to the table. A lot of other stuff has to happen in that process (checking the project number on the form, assigning an ID tag for that item, etc).

View 3 Replies View Related

Modules & VBA :: Download File From Url And Import To Table

Sep 2, 2013

i am trying to download an excel document from a url and the import it into a table i can successfully download the file to my desktop but when i try to import it i get the below error the Microsoft office access database engine cannot open or write to file 'C:documents and settingsJHalliweDesktop' it is already opened exclusively by another user, or you need permission to view and write its data..i have checked and the excel book is not open ( i think its trying to open while its still downloading is there away around this

Code:
Dim strUserName As String
strUserName = Environ("UserName")
Dim FolderLoc As String
FolderLoc = "C:Documents and Settings" & strUserName & "Desktop"
Dim StFile As String
Dim MySelect
MySelect = Forms!FrmIndex!Text134

[code]....

View 3 Replies View Related

Modules & VBA :: Data Type To Be Changed In Import

Sep 1, 2014

I have excel, which i want to import in Access, but i need data type to get changed as text when imported, how can i do that?

View 2 Replies View Related

Modules & VBA :: Import To Excel - Add Criteria To Set Range

Mar 18, 2015

I've adapted some code I found which works and allows me to import data from my access table "Device Text" to a specific range in an existing excel worksheet by copying a field "TextEdit" in the recordset. the code is placed in a module behind a command button on an excel worksheet. I have used import to excel because this seems to be less complicated for my needs than exporting from access.

Everything works fine if a single range is set , however I would like to set the range(rng) criteria in the code below to start at a certain cell depending on the value in another field in my access table called "LoopID" this is a number field which is not unique and can be 1,2,3 or 4. I know it wont be evaluated but I've entered the gist in red in my code.

I don't need to import it but I suspect I have to bring LoopID into the recordset somehow to use it,

Code:
'DIM STATEMENTS
Dim strMyPath As String, strDBName As String, strDB As String, strSQL As String
Dim i As Long, n As Long, lFieldCount As Long
Dim rng As Range
'instantiate an ADO object using Dim with the New keyword:

[Code] .....

View 5 Replies View Related

Modules & VBA :: Import Spreadsheet With Form Variables

Jul 18, 2013

I'm looking at importing data into a table from a spreadsheet. The spreadsheet will only contain a single column of data, while the table in Access will have a few more, some of which will would be will provided from the form the user is using to import the data, and some at a later date.

Is there a way to do this? I've found the "DoCmd.TransferSpreadsheet acImport" command, but not sure this fulfills what I need, as I can't see a way to set variable data.

Here is a brief idea of what my Table would look like, where where the data to import would be obtained from

Fields:
PromoID, DiscountID, PromoCode, AddedBy, DateAdded, UsedBy, DateUsed

Spreadsheet
PromoCode

Form:
DiscountID, AddedBy (environ("username") query), Date ( DATE() )

Note, the PromoID is a autonumber.

View 2 Replies View Related

Modules & VBA :: Import Files Listed In A Table

Jul 20, 2015

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).

The code that loads up the files is this:

Application.ImportXML DataSource:="C:ImportXML FILES" & FileName & ".xml", _
ImportOptions:=acAppendData

Up until now I specify the name of the file in an inputbox, so I have to enter a bunch of names to get it done.

I am looking for a way to get the filename from the table and then load up the file automatically.

View 1 Replies View Related

Modules & VBA :: Invalid Character In Import String

Jun 16, 2015

I have a program that has been working for a year or so, it imports records form a text file created by a web site. Someone has entered a hex("1A", "A8" in a name field. It is shutting my program down. I tried a alphanumeric check to replace it and a length check to try and skip the record but the program thinks it is at the end of the file and quits reading records. Is there a way to get rid of characters like this in vba?

"5407 MUYF3I23 GIS..LE "

Here is what I have tried

Code:
If Len(strread) <> 591 Then
MsgBox "Invalid Record Read " & strread
GoTo Skip_Loop
End If
If AlphaNumeric(CStr(Trim(Mid(strread, 32, 11)))) Then
!HT_FName = CStr(Trim(Mid(strread, 32, 11)))

[Code] .....

View 9 Replies View Related

Modules & VBA :: Import Specific Worksheet From Excel

Aug 11, 2015

I am new to MS Access and have been trying to use VBA to import a specific worksheet called "Access" in an Excel file (from about 400 users) into a single table. I want the code to search through one folder and import the "Access" worksheet in each Excel workbook within that folder. Each user has the same worksheet name. Here's my problem. I got this VBA code from: AccessMVP where KDSnell gave examples of how to import Excel worksheets into MS Access Tables.

Sub ImportExcel()
Dim strPathFile As String, strFile As String, strPath As String
Dim blnHasFieldNames As Boolean
Dim intWorksheets As Integer
' Replace 3 with the number of worksheets to be imported
' from each EXCEL file

[Code] ....

When I execute the code. Nothing happens. I go to the table and find nothing....or I get Runtime error 3011, where MS Access can not find the object "Access". Also, is it possible to update the table without duplicating records?

I'm using Excel 2010 and Access 2010.

View 5 Replies View Related

Modules & VBA :: Import Button To Ask For Location Of File

Oct 22, 2013

I have been searching all over on how to create an import button on a form in access 2010 where I can set which table it should copy the data into but the user could locate the import file.

NOTE: the reason being I have locked all the ribbons...

If necessary I could make a specific import template file which would have all the headings locked...

View 4 Replies View Related

Modules & VBA :: Import Excel Into Access With A Default Value

Jun 6, 2014

I'm stuck on a step where I want to import an excel worksheet into the msaccess like we do normally. I do not have any data inside, it's just the header I will be importing. The data will be feeded by other forms based on some selections. My requirement is the "Default value" of each field should be set to 1 as we see in the property of a table in design mode.

The data would be updated later for some fields via macro or commands, but the fields were nor touched should be set to 1 (Value).

View 4 Replies View Related

Modules & VBA :: Function To Import Most Recent File

Sep 29, 2014

There is a manual process I'd like to automate. Instead of the user manually importing an external file into a table, I want a function to grab the most recent file in a particular directory. Is that possible?For example, I have a table called Input, and I want to append the file I just saved on my network, which in this case is G:Files2014TA_140928_011007.txt. The two ways to know which file to use is that the date is part of the filename (TA_ YYMMDD_ 999999. txt), and also the Date Modified attribute.

I am aware that if the user needs to work the files out of date order, he/she cannot use this code.

View 1 Replies View Related

Modules & VBA :: Import Error Auto Redirecting

Nov 14, 2014

When I import an excel sheet into Microsoft Access database tables, I get a automatic [table name]_$importErrors table generated. Almost always, errors are type mismatch error. Then, I need to go manually fix the cells.

Is there a way to automatically point to excel cell(s) which have error(s)? I am trying to write a VBA code which opens an excel sheet if an "importError" table gets generated automatically after import. Then, it goes directly to a cell in the sheet where it has errors with a click of button in the Access form.

View 1 Replies View Related

Modules & VBA :: Format XML Date For Import Into Access

Apr 12, 2014

I've written a vba macro that takes data from Excel, processes it into an XML file & then imports into Access.All fields were fine apart from the date field, which appeared in the Access table as "00:00:00"...The date in the XML was appearing as 01/01/2014.

Code:

dateTemp = [date here]
xmlFieldElement.Text = Year(dateTemp) & "-" & Format(Month(dateTemp), "00") & "-" & Format(Day(dateTemp), "00") & "T00:00:00"

This produces 2014-01-01T00:00:00...Note, putting the date into reverse order without the formatting also causes the import to result in 00:00:00

View 1 Replies View Related

Modules & VBA :: Import Only Sheet Names Into A Table

Dec 28, 2013

I have an excel file on my drive with the following path "D:JsonSolve.xlsx", I only want to get "Sheet Names" and Import the sheet name into a table in Microsoft Access, how to import "All Sheet Names" from the specified path into a table, Every sheet name would be taken as a single record.

View 4 Replies View Related

Modules & VBA :: XML Import - Adding Data To Tables

Apr 8, 2014

Looking for (semi) generic piece of code that knows how to handle (semi) random XML files and structures, preferably creating tables and columns on the fly...

Or some code that will read an XML tree and genericaly will add the data to the tables it can find?

View 2 Replies View Related

Modules & VBA :: Import From Excel (variable Ranges)

Jun 12, 2014

I am trying to import data from an Excel file to MS Access (2013).

The Excel sheet consists of 700 columns. A group of 7 columns (always same header) are to be implement in Access one among the other.

That means:

At first columns A-G, than columns H-N, than columns O-U

I am trying to solve this with a loop (as you can see in the code)

But, if I start the modul I get this error:

"Runtime error 1004. The method Worksheets for _Global object failed"

But the module works, of I start it a second time. The error message appears only at the first start.

Apart from that, the code works. Sometimes, the module imported empty rows into the Access table.

Code:
Sub ExcelImport()
Dim xlApp As Excel.Application
Set xlApp = New Excel.Application
xlApp.Workbooks.Open FileName:="C:Users...DesktopBeispiel.xlsx"

[Code] ......

View 1 Replies View Related

Modules & VBA :: Get XML From A Site And Import Data To Access

Dec 4, 2014

I get XML's from a site and want to import the data to Access. If I use the native import then I get multiple tables and the data is a little jumbled. For instance: I get 1 table with track names and a different table for track numbers with no way to relate the to accurately. I would like to be able to parse out the XML and have it update my table as it goes so I have less "junk" in my DB. I just can't figure out how to call out the XML tag and tell it to copy that info to the correct field.

View 1 Replies View Related

Modules & VBA :: Automating Daily Import Of CSV File

Aug 10, 2013

We receive a daily csv file from another database and we are trying to automate this process as much as possible.

At the moment, the other system will extract any new records, save a file as importddmmyyyy.csv in a specified location e.g. c:importpendingimportddmmyyyy.csv and then make a call to open access giving access the file path as follows

masaccess.exe "C:mydatabase.mdb" /nostartup / Excl/ cmd Filepath="c:importpendingimport09082013.csv"

I have configured access to automatically open a form, "ImportForm" when it opens, and I have configured this form to automatically run an event procedure on loading "importdailyfile".

My problem lies in writing this procedure. Basically I need it to run the Transfer Text command (I have already create an import specification)

DoCmd.TransferText acImportDelim, "myimportspec", "table to append the data to", filepath, true

The problem I am facing is that as the filepath changes on a daily basis given the naming conventions (which i cannot change) and my knowledge of VBA s pretty basic, I don't know how to make the procedure pick up the filepath that the other system is providing in the call to open access.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved