Modules & VBA :: Upload CSV To Array And Then Add Records To Table

Jun 9, 2013

I'm trying to upload a csv file into an Array then add records to a table. I have the following code which gets the information from a csv file which works fine.

Open filePath For Input As #1
Do While Not EOF(1)
Line Input #1, MyData

Problems:
1. When i try to load this into an array , it does not return all the information. It will if a smaller amount of data is sought. For example if only 1 months month of data is requested. Is there a maximum data limit that can be parsed into an array with this method?

2. I'm not quite sure how to parse individual lines (records) to update a table in access. I have provided the code that I'm trying to use to accomplish this below. From code below am I doing this correctly?

3. For each record that is created in the database I would like to add a ticker string to the record for later querying. Can this be done and am I on the right track from the supplied code?

Private Sub ImportData(filePath As String, ticker As String)
'On Error GoTo Errorhandler
Dim arrData() As String
Dim MyData As String
Dim i As Integer
Dim Db As DAO.Database

[Code] ....

View Replies


ADVERTISEMENT

Add Records To Table In Bulk (not One Record At A Time) Via Multidimensional Array

Aug 13, 2015

I'd like to add 600+ records at a time to a table (or at least a lot) and do this 1200 or so times. Yes, this is a very big table, its okay and the size is not an issue.

The key here is that speed is very important. I DO NOT want to AddNew and Update a recordset 700k times (one for each new record). I want to add 600 records or so 1200 or so times.

I am open to any way of doing this in VBA and/or SQL in MS Access; however, I am thinking of building an array that has 600 rows and 16 columns, then somehow add that to the table all at once. I will size the array down if it causes problems. That isn't the issue. The issue is how to add a 2d array to a table in bulk (all at once).

Code:
Sub test()
Dim dbLocal As DAO.Database
Set dbLocal = CurrentDb()
Dim sql As String
'build my array
Dim x(0 To 1, 0 To 1) As Integer

[Code] ....

View 14 Replies View Related

How To Upload Data From Ms-Exell Ms-Access Table Automatically?

Oct 27, 2006

I am Oracle Guy & new to Ms-Access. I want to load the data from Ms-Exell into Table in Ms-Access automatically through Procedure / Macros. How to do this process?. Help me, if anyone knows.

Regards,
GKS:mad:

View 3 Replies View Related

Modules & VBA :: Send OpenArgs As Array?

Apr 28, 2015

Is it possible to send several form's OpnArg as Array ? Now I'm using a long text string including || as divider so I can split them later into Array.

View 8 Replies View Related

Modules & VBA :: Parsing Array Value To Form

Nov 14, 2013

I am having a problem with parsing the array value to Forms!<arraryvaluehere>.dirty.

Please see the code below:

Public strListOfForms(0 To 2) As String
strListOfForms(0) = "frmForm1"
strListOfForms(1) = "frmForm2"
strListOfForms(2) = "frmForm3"
For i = 0 To 2

Debug.Print CurrentProject.AllForms(strListOfForms(i)).IsLoaded
Debug.Print Forms!strListOfForms(i).Dirty

Next i

Note: CurrentProject.AllForms(strListOfForms(i)).IsLoade d works and Forms!strListOfForms(i).Dirty does not.

Is this because it is taking "strListOfForms(i)" literally? Is there a way that I can get around this?

View 1 Replies View Related

Modules & VBA :: Using Array To Populate ListBox

Apr 7, 2014

I have some code that successfully gathers some items and adds these items to a listbox, one item at a time using .AddItem.And it works ok.The problem is, when there are a bunch of items to add, everytime the .AddItem runs, the form redraws.there are a bunch and this leads to a lot of flicking while the form redraws however many times .AddItem adds an item.

I've had the idea of building an array and then assigning the array to the listbox.I can build the arrray no problem but i have not been able to assign the array to the listbox all at once.how to do is add items to the listbox from the array one specific item ListArray(i) at a time.

Obviously this would work, but gains me nothing in terms of the visual effect in the form becuase it is still adding to the listbox one item at a time.Is there some way to assign an array to a list box all at once, without doing it one item at a time?

View 3 Replies View Related

Modules & VBA :: Deleting Values In Array?

Jul 1, 2013

How do I delete values in an array? I want to reuse that array but first I need to delete its values so I would start with Arr(0) rather than where I stopped off with the last loop at Arr(10) [assuming the last calculation inserted until Arr(9)]

Here is my code:

Set rst = CurrentDb.OpenRecordset( _
"Select * from dbo_ProductStructure where ChildProductNbr Like '*" & txtPartNumber & "*'") 'search associated fields with user input
While rst.EOF = False
ReDim Preserve Arr(i)
Arr(i) = rst.Fields("ParentProductNbr")
i = i + 1
rst.MoveNext

Wend 'end of while loop

x = Arr

View 9 Replies View Related

Modules & VBA :: Empty Values In Array

Aug 16, 2013

I'm trying to store all the OrderNumber + Item combinations in 2 arrays and then because the OrderNumber column really contains 2 values I'm interested in, I split it up and store that column's values in 2 arrays. So in total, I have 3 arrays. An array for Item, an array for Order, and an array for RepId (which is the one that I split up from the OrderNumber column).

Anyways, when I print the RepId array with the ' MsgBox PostValCol1(x) ' It prints 4 values like it's supposed to. But when I tested it again by looping through the values and just doing a MsgBox, It goes for a long time and that's because it has a lot of empty values in that array. How to get rid of those empty values/not store them in the first place?

Code:

Set rop = CurrentDb.OpenRecordset("Select OrderNumber, ItemNumber From dbo_EntryStructure Where (ProductNumber = '" & txtPartNumber & "') AND (ActionCode = 'I')")

While rop.EOF = False
ReDim Preserve ArrRepOrder(j)
ReDim Preserve ArrItem(j)

[Code] .....

View 3 Replies View Related

Modules & VBA :: Retrieving Array Returned From PHP

Mar 11, 2014

I have an Access Database that I will be using on a desktop. I have a table in this database that mirrors the structure of a table on a remote server in a SQL database. I have successfully created a vba function within the Access database that uses a server-side php subroutine to select records (I usually won't know how many) from the SQL database and return them to the access database. The code I use in the access vba subroutine to access the php subroutine is:

Code:
With CreateObject("Shell.Application").Windows
Set ieWindow = CreateObject("InternetExplorer.Application")
ieWindow.Visible = False
apiShowWindow ieWindow.hwnd, SW_MAXIMIZE
ieWindow.Navigate "Web address for server-side php file"
End With

The last command in my php subroutine is "return $retrievedData." $retrievedData is a multidimensional array containing data from 42 fields in multiple records (again, I usually won't know how many). I've checked the data in php so I know it has been stored correctly.how do I access the returned data within my access vba subroutine?

I should add that my overall reason for doing it this way is that I want to maintain my server-side database as an untouched master. Users can only add data to it. My client-side database is used to update the input table and further process the data. The subroutines described above are intended to retrieve "new" records only (i.e., records posted since the last access database update) from the server-side database and transfer them to the access database for further processing.

View 3 Replies View Related

Modules & VBA :: Using Select Case Statement With Array?

Jun 26, 2014

I have a boolean array, foundState(3), whose 4 elements correspond to 4 variables describing conditions that will dictate what action is taken upon closing a form.

There are only 6 possible outcomes for the array, and they can be divided into just 4 cases:

Case {T,T,T,T}

Case {T,T,T,F} OR {T,T,F,F} OR {T,T,F,T}

Case {T,F,F,F}

Case {F,F,F,F}

What the proper syntax would be for this if I'm trying to create a "Select Case" statement for these 4 cases.

View 7 Replies View Related

Modules & VBA :: How To Make Array And For Each Statement Work Together

Aug 23, 2013

how I can make an Array and For Each statement work together. I normally don't use either, but it would be good so I could write less code where plausible. Here is the example I have:

Code:
Dim Named As Variant
Dim Ctl As Control
Named = Array(Me.Namee, Me.ID, Me.Title)

[code]....

I am unsure how I include the array in this statement. I have tried replacing "Me.Controls" with the array name, but I get a 424 runtime error (no object). What I am trying to accomplish is for each item in the array I want to make it not visible if it has a null value.

View 7 Replies View Related

Modules & VBA :: Find Duplicates Of Values In Array

Oct 4, 2014

I have to deal with string arrays that store text. I need info on copying, comparing, appending arrays. Also on passing arrays as parameters to subs or functions. Where I can get to this info quickly without having to browse through many screens.

In addition to this I have some questions:

I have to find the duplicates of values in an array. Here is the code that I use.

Code:
Sub FindDuplicates()
Dim I As Integer, J As Integer, IEND As Integer, text() As String
ReDim text(IEND)
For I = 1 To IEND - 1
For J = I + 1 To IEND
If text(I) = text(J) Then text(J) = ""
Next J
Next I
End Sub

It works but is not performing well. Are there more efficient ways of doing this?

View 14 Replies View Related

Modules & VBA :: How To Pass Only Single Dimension Of Array

Jul 31, 2014

Now the getrows is working fine at my end. Now I have a different problem at hand:

Sub Test2()
Dim myrset As Recordset
Set myrset = CurrentDb.OpenRecordset("SELECT * FROM Holidays;")
myrset.MoveLast

[Code]....

Recordcount is coming fine
Manual Array is also giving the right result
But the Index method is giving the wrong value. Why?

(Holidays table is just having the values in the array only ie. #08/15/2014# and #08/29/2014#)

View 7 Replies View Related

Modules & VBA :: How To Read TXT File Into Array For Processing

Oct 23, 2014

I'm getting an error when trying to read a .txt file into an array for processing. The error and a snippet of the code are below.

Run-time error '9'
Subscript out of range

Dim iFileNum As String
Dim strLineInfo()
Dim i As Integer
Dim strExpensesFile As String
strExpensesFile = "c:FinanceExpensesIn.Txt"

[Code] .....

View 9 Replies View Related

Modules & VBA :: String Into Numbers - Using Array For Lookup

Jan 15, 2014

I have to decode a string into numbers and to avoid to find out the values for 47 options by select case I though about an array.

I want to decode

Number Letter
10 A
11 B
12 C
13 D
14 E
15 F
16 G
17 H
18 I
19 J
20 K
...

For example the string "ADEG" would give as result
10 13 14 16

So I would have to loop through the string and "decode" each letter into a number.

As I have still problems to understand array, need to define the dimension of the array, it has fix 47 entries to decode

Dim myarray (47,2) as variant
mayarray=(10,"A",11,"B",...)

Correct?

View 10 Replies View Related

Modules & VBA :: Populate Array And Use Values In Another Function

Jul 16, 2013

I've created an array that I created and declared as a Public array in my module. I created a function that populates the array so that I can use the values in another function. I've gotten the array to populate but when I go to use the values in the array in another function, the array appears at Empty. I seem to be stuck on declaring it properly or something so that it can be used by other functions.

Public arrWebIDs As String
Public Function FillArray()

View 6 Replies View Related

Modules & VBA :: Report Names - Changing Settings For Array

Nov 6, 2014

I have the following script which I use to modify all report settings, with an array so that I can easily list reports that I want to change the settings for, there could be 50+ reports.

I can use a string but I have to put str1 as string, str2 as string etc... whereas an array would be easier (if I knew how to do it).

Code:
Public Sub ModifyAllReportsProperties()
Dim obj As AccessObject, dbs As Object
Set dbs = Application.CurrentProject
Dim ReportName As String

[Code] ....

View 9 Replies View Related

Modules & VBA :: Array Parameter Invokes Invalid Qualifier

Nov 11, 2013

So I have a sub, here:

Code:
Public Sub AppendClause(Clauses() As String, Item As CheckBox, Column As String)
Select Case True
Case IsNull(Item.Value)
Return
Case (Item.Value = -1)
Clauses.Append ("'" + Column + "'" + "=true")
Case (Item.Value = 0)
Clauses.Append ("'" + Column + "'" + "=false")
End Select
End Sub

The problem I'm having is that Clauses.Append causes a "Invalid Qualifier" error to happen. I know that error means it doesn't recognize anything within scope that has that name.. But I'm obviously defining it in the parameters.

View 5 Replies View Related

Modules & VBA :: Checking Array - Subscript Is Out Of Range If Value Is Equal To D

Aug 6, 2013

I am having trouble checking if the last array value is equal to 'D'.

This is what i have so far but it keeps saying that 'subscript is out of range'... 'g' by the way is equal to 1. It just really means that there's only one value in ArrAC.

Code : If Not ArrAC(g) = "D" Then

View 2 Replies View Related

Modules & VBA :: Send Emails To Defined Array Of Recipients Using CDO

Sep 18, 2013

I am trying to send emails using CDO to an array of recipients loaded from a query. I have made this work using Lotus Notes so i know the first part of my code is correct, and the current code I have works when I input an actual email address. But when I try to add the Array name into the 'To' field I get a data mismatch error.

View 3 Replies View Related

Modules & VBA :: CSV File Manipulation - Parsing Data Into Array

Jun 9, 2013

I'm trying to parse the following into an Array by splitting the csv file using a "," comma separator. There should be 63 different data pieces in this File. When I do a count of them from the (ubound array) i only get 54. The last data piece on each row gets concatenated to the first data piece of the next line. Is there a way to stop this from happening? This is causing problems with working with the data.

Date,Open,High,Low,Close,Volume,Adj Close
2013-06-07,1625.27,1644.40,1625.27,1643.38,3371990000,1643 .38
2013-06-06,1609.29,1622.56,1598.23,1622.56,3547380000,1622 .56
2013-06-05,1629.05,1629.31,1607.09,1608.90,3632350000,1608 .90
2013-06-04,1640.73,1646.53,1623.62,1631.38,3653840000,1631 .38
2013-06-03,1631.71,1640.42,1622.72,1640.42,3952070000,1640 .42
2013-05-31,1652.13,1658.99,1630.74,1630.74,4099600000,1630 .74
2013-05-30,1649.14,1661.91,1648.61,1654.41,3498620000,1654 .41
2013-05-29,1656.57,1656.57,1640.05,1648.36,3587140000,1648 .36

View 3 Replies View Related

Modules & VBA :: Using Array To Store Selected Items In List Box

Apr 10, 2015

I want to use an array to store data from a list box into a variable. I want it to be able to store one value, or multiple values, depending on what is selected.

Main problem: this list box feeds off a table which has employee names and their e-mails. The list box itself only shows the names, and when I select what I want the array to store is their e-mails, not their names.

Code:
Dim strNames As String
Dim varItem As Variant
Dim intCount As Integer
For Each varItem In Me.lstNames.ItemsSelected
intCount = intCount + 1
Select Case Len(strNames)

[Code] ....

That code successfully displays the item I selected, but only displays the name. I need to make it look in the table and get me column #2. I also want it to be able to select more than one item at a time.

View 5 Replies View Related

Modules & VBA :: Save Input Into Array And Show This Information

Nov 23, 2013

I want to save input into an Array, and then show this information.To enter data I am using a textBox. After "Enter" it should save info into the Array.If textBox is empty, it should show information. I would like to use a textbox too, that shows all the Array after pressing Enter.

textbox on the Form: txtInput, txtOutput..I have the following code, but I am not able to get it work:

Code:

Option Compare Database
Public Sub Form_Load()
Dim Data(10) As Integer
Dim i As Integer
Dim j As Integer

[code]...

View 4 Replies View Related

Modules & VBA :: Normalize Data In Array / Remove Duplicates And Import

Dec 18, 2013

I have some data in an array that I need to normalize, remove duplicates, and import.

Original Table

Every record in the array has a person, all but a few have an address, most have a phone, and some have an email.

Person----- Address ----- Phone ----- Email
Tom ----- 10 A Ln ----- 789... ----- e@a
Sue ----- 20 B Ln ----- 256... ----- _____
Sam ----- 30 C Ln ----- _____ ----- _____
Dan ----- 40 D Ln ----- 478... ----- _____
Jan ----- 40 D Ln ----- 567... ----- e@d
Stu ----- 50 E Ln ----- _____ ----- _____
Syd ----- ______ ------ 224... ----- _____

New Data Structure

I want to group the data by HouseHold; which Address will serve to define for this import.

tblHouseHold
hhID
tblAddress
adrID, hhID, Address
tblPerson
prsID, hhID, Person
tblPhone
phnID, hhID, Phone
tblEmail
emlID, hhID, Email

I've been working on a procedure to step through the recordset and add the data one record at a time so I can get rid of the duplicates.

I've tried a few approaches, but this is where I'm at now.

Code:

Dim rs As DAO.Recordset
Dim rsHH As DAO.Recordset
Dim rsPhone As DAO.Recordset
Dim rsEmail As DAO.Recordset
Dim rsAddress As DAO.Recordset
Dim rsPerson As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb

[Code] .....

View 2 Replies View Related

Modules & VBA :: Creating Recordset - Using Array As Report Data Source

Apr 17, 2015

I've done some basic work with arrays.. writing array data to form list objects.. How to use an array as a data source for a report?

Would i need to create a recordset and populate it with the array, then bind the report to it ?

The reason I am asking is the previous developer here built every app using arrays and UDT's... the apps are completely disconnected from the data. Everything is loaded in to arrays..

View 2 Replies View Related

Deleting Query Table With An Array

Apr 11, 2008

Hi, I have a problem deleting a specific row and field that my query have.

What I want to do is mainly delete a specific rows in the my Query table that has : Field 1, Field 2, Field 3, Field4

what i tried to do was doing is create and array that loop through the Query table and check in field 1 for a certain value and if that certain value appears I want to delete that row: for example

Dim IntRow As Integer
Dim IntCol As Integer
Dim varData As Variant


For IntCol = 0 To numFields Step 1
For IntRow = 0 To numRows Step 1
If (rst.EOF = False) Then
'Check Field 1 for value 47-72 to delete
Else
If (varData(0,IntRow) > 47 And varData(0,IntRow) < 72) Then
varData(IntCol, IntRow).Delete
End If
End If
Next IntRow
Next IntCol



In the example Above my syntax is not correct for :
If (varData(0,IntRow) > 47 And varData(0,IntRow) < 72)
and for varData(IntCol, IntRow).Delete.

can anyone help me to find the exact syntax i need to use to execute the program above?

THANK YOU!

View 2 Replies View Related







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