Insert Ado Recordset Into Table
Sep 23, 2009
I'm getting extremely frustrated with trying to find some code that allows me to paste an ADO recordset into a database table!
What I am doing is on a weekly basis is creating a plan of which containers my company needs to devan. We have a system that stores shipping information about these containers and I get shipping information delivered to me via e-mail from one of our major shipping companies. Their data is more accurate so what I do is paste the data I get from them into my container planning sheet and import it into out Teradata Warehouse to query against using ADO and I import this one record at a time. This is extremely slow!
In order to get around this I want to create a recordset from this data and then paste the recordset into a table in the database. So far this is my ....
View 9 Replies
ADVERTISEMENT
Nov 15, 2006
Is there an example outthere that will demonstrate how to create a pivot table using an ADO Recordset? I'll be experimenting tommorow but really don't relish the thought of spending 12 hours trying to figure it out.
View 2 Replies
View Related
Nov 1, 2008
I'm looking for an example of creating a pivot table based on an ADO Access Recordset.
I understand I can use MS Query - which I am, but looking to see if an alternative exists. A table I am inetrested in currently has 400,000 records I would like to retrieve and pivot.
View 9 Replies
View Related
Feb 25, 2013
i have a created a connection with Access table named Test, the table has 3 fields, ID,Firstname and LastName. The values in field firstName is filled in a Combox which is in Sheet1 of excel sheet.
so far i have done with the coding which create a connection with access table and fille all the firstname from the table to the Combobox using a recordset.
the code for filling combobox value from records set is like
Do Until RecordSet.EOF
shp.ControlFormat.AddItem RecordSet.Fields("Name").Value
RecordSet.MoveNext
Loop
Now what I need is whenever I select a name in a combobox the Cell A1 in excel should show me the LastName for that name.
I am not very sure if we can use offset in this.
View 3 Replies
View Related
Dec 29, 2008
i have a select statement, that pulls one row from access and i need to get the data and assign it to different fields in a userform. however, because it only pulls one row, its at .eof and closes, so any following statements cause errors because the recordset is closed.
qc.Open "SELECT * FROM [Equipment_Table] WHERE [Equipment_QC] =" & combobox12.text, cn, adOpenStatic
Equipment_Title.text = qc.fields.item("Equipment_Title")
Equip_File = qc.fields.item("Equipment_File")
Equip_ID = qc.fields.item("Equipment_ID")
View 9 Replies
View Related
Jan 25, 2012
I got a recordset which I get from a database (I use ADO).
I want to delete every entry in that recordset from the database.
View 4 Replies
View Related
Feb 28, 2014
I've Created Connectionstring for excel which is in database format and trying to get the data by comparing 2 sheets using he below code.. But not working..
Set ws = Sheet1
sSQL = ""
sSQL = "SELECT [Company Code], "
[Code].....
View 1 Replies
View Related
Jul 28, 2008
Currently, my code involves making a connection to a db then run queries. Results from the queries goes to recordset & from the recordset copy to specified range in excel worksheet. I am trying to do an automation process.
The problem is that once the record is pasted in excel worksheet, the date column is not being recognised as date therefore excel function (vlookup) is not giving me the results in my report.
When i do a manual PasteSpecail as CSV into the worksheet from the query result, my report gets populated with data which is correct.
i've tried doing a pastespecial format:="CSV" but it doesnt work.
Is there any codes that i can use to copy from the recordset as a CSV format pastespecial??
Or any other ways that can be done?
View 9 Replies
View Related
Sep 24, 2009
I have been creating pivot tables (from the active workbook) with ADO for a while and its working great.
I just tried to switch to DAO and adapted my code accordingly but the new code fail at:
Code: ....
View 9 Replies
View Related
Nov 8, 2011
When I read a CSV file into a recordset, the headers are not all being read. I get gaps in the headers for whatever reason. Attached below is the Function to load the recordset from the file. I have hard coded Hdr to "No" in the connection string.
Code:
Function QueryByID(tableName As String, fieldToQuery As String, Target As Long, Hdr As String) As Recordset
Dim strFilePath, strFileName, strQuery As String
Dim oFSObj, oConn As Object
Dim oRs As Recordset
Dim f, lastRow As Integer
[Code] .......
The below is how I output the resultset:
Code:
Sub OutputResultSet(aTable As String)
Dim row, col, i, j As Integer
row = 1
col = 1
ThisWorkbook.Sheets(aTable).Activate
[Code] .....
I have triple checked the CSV file and the first row in each file has definitely got headers. Some headers are loaded and output fine, others are just blank.
View 5 Replies
View Related
Jan 17, 2012
I want to fill a listbox with values from a database.
The query et al. works just fine, but I cant get the listbox filled.
Is there a command to fill the listbox with all the entries in the recordset at once?
View 5 Replies
View Related
Nov 30, 2009
I have a sub-routine I call on that takes a current recordset and converts it to an Array.
I would like to make this sub-routine tool more flexable by being able to specify THE NAMES for the recordset and an array involved.
For example
Sub My_Code()
....blal bla bla.... current code...
Call Recordset_To_Array( Recordset_name, Array_name )
....bla bla bla... continued
end sub
And the subroutine tool:
Sub Recordset_To_Array( Recordset_name as String, Array_name as string )
'Code that generates RS
'Need to take Recordset_name string value and use it in the line below at "XXXXX"
Dim XXXXX as Recordset
'Code that generates array
'Need to take Array_name string value and use it in the line below at "XXXXX"
Dim XXXXX as Variant
End Sub
View 9 Replies
View Related
Oct 14, 2006
how i can display different values using the Selection.FormulaArray, ok look at my
Dim mySheet As Worksheet
' On Error GoTo errors
Dim x As Integer
x = TextBox1.Text
Dim y As Integer
y = RefEdit2.value
Set mySheet = Excel.ActiveSheet
mySheet. Range(RefEdit1).Select
Selection.FormulaArray = "=multiplie_value(""" & x & """, """ & y & """)"
MsgBox Selection.FormulaArray
Now the function i call:
Public Function multiplie_value(valor As Integer, multiplo As Integer) As Integer
multiplie_value = Val(valor) * multiplo
End Function
thats an example. so the real question is i create a form, the user enter some values to search to a database, the user select an area(a range) where they want the data to be display, but i dont how to display that info that is coming from the database in the range that the user selected. The info displayed in the range should look like a tabular report, column headers, etc.
View 9 Replies
View Related
May 9, 2012
I have a function that loops through sheets and opens a query and copys the information to a sheet. I have gone in the access db and updated the query. Yet everytime i call it in excel it returns the old data. I have gone into access and verified what data I should get and I just don't get it.
I pass in the query name and the sheet name into qryName and sheetName name.
Code:
Dim cnn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sQRY As String
Dim strFilePath As String
[Code].....
View 1 Replies
View Related
Sep 12, 2013
I am trying to run a prestored query in a Access database and popuate the result into a Recordset --- through Excel. So far, I have managed to accomplish that using the code below. However, now I need to update some records in the recordset. The code below does not allow me to do so.
The following message prompted when the code tried to update the record: Run-time error '3251' Current Recordset does not support updating. This may be a limitation of the provider, or of the selected locktype.
This is written for other users who only knows how to create a query in Access. And the users prefer not to import the query results to spreadsheet.
*Someone suggested use Recordset.Open however, that seems to work only with SQL statement but not prestored Queries.
Code:
Sub RunExistingQuery()
'Execute prestored queries in Access
Dim Con As ADODB.Connection
[Code].....
View 2 Replies
View Related
Jul 20, 2009
I am trying to populate a 3 column listbox in a userform from SQL Server via ADO. When the result set consists of more than one record, there is no problem and the data is displayed properly (ie each piece of data is in its appropriate column) eg...
StockCode..........QtyReqd.........JobDeliveryDate
test1...................1................. 01/01/1900
test2...................1..................31/12/1900
test3...................3..................18/02/1900
however when the recordset returns only a single record, the data does not transpose and views as below (ie each piece of data in the record is on a different line in the first column
StockCode...........QtyReqd.........JobDeliveryDate
test1
1
01/01/1900
View 12 Replies
View Related
Mar 13, 2013
I am having trouble setting up a query for a recordset that will list duplicates for an automated process to clean up. I am using Excel 2010 with Microsoft ActiveX Data Objects Recordset 6.0 Library and Microsoft ActiveX Data Objects 6.1 Library as references.
So far, I have chopped the query down to it's most basic elements and reassembled until it broke. Necessary pieces work well, but when I combine them, I get nowhere.
Here is the working simple query to retrieve a single row:
Code:
dupeSQL = "SELECT PSID FROM [Obstructed$] "
Here is the working single query to retrieve a count:
Code:
dupeSQL = "SELECT COUNT(PSID) As '" & "CountPSID" & "' " _
& "FROM [Obstructed$] "
When combined, I cannot figure out why it won't work:
Code:
dupeSQL = "SELECT [PSID], COUNT(PSID) As '" & "CountPSID" & "' " _
& "FROM [Obstructed$] "
Here is what I am trying to get to:
Code:
dupeSQL = "SELECT [PSID], COUNT(PSID) As '" & "CountPSID" & "' " _
& "FROM [Obstructed$] " _
& "WHERE COUNT(PSID) > 1 " _
& "GROUP BY PSID"
I can even work without the GROUP BY. I have also played with the HAVING clause to try and accommodate the [PSID] field, but have gotten nowhere.
View 1 Replies
View Related
Jan 16, 2012
How to insert a column to table depending upon name of the other column using VBA.
Like i need to insert the column in a table besides the column name x.
So how to search for column name x and insert column besides it.
View 2 Replies
View Related
Apr 26, 2012
Im trying to find the best way to insert data into table.
source of data is workbook range and/or array the obvious one is
Code:
With Sheets(1).ListObjects(1).ListRows.Add.Range
Cells(1, 1).Value = xxx
Cells(1, 2).Value = yyy
Cells(1, 3).Value = zzzz
end with
but if its lots of data it could get very slow.
Q1. is there a way how to insert multiple records at once, something like
Code:
'does not work
With Sheets(1).ListObjects(1).ListRows.Add
.Range(Cells(1, 1), Cells(1, 3)).Value = arrXXX
End With
I found it faster to store data into array and then paste them
Code:
rw = ListObjects(1).HeaderRowRange.Row + ListObjects(1).ListRows.Count + 1
range(cells(rw,1),cells(rw,3).value = arrXXX
but I had issues with it especially if the destination table has some filters applied. I'd also prefer not to clear the filters during the sub
Q2. are there any other options that would be fast and reliable?
View 3 Replies
View Related
May 21, 2008
RowCount = Worksheets("T_Stunden").Range("A1").CurrentRegion.Rows.Count
With Worksheets("T_Stunden").Range("A1")
[code]
I need to change it so it goes into the table as at the moment it goes one line below when I finish with the entry via Userform.
View 9 Replies
View Related
Dec 11, 2013
I am working on an excel table in my worksheet contains formulas and locked cells. lets say table range is from column "a" to "f" and there is formula on cell in columns "c" and "f". I just locked cells in column "c" and "f" to prevent people changing the formula accidentally. but when the sheet is protected i am not able to insert or delete rows as the rows has locked cells in columns "c" and "f".
I tried the below macro to unlock the sheet, insert row and lock the sheet again:
[Code] .....
So by running the macro it asks the password and do the job but the issue is it needs password and i do not want people to know my password. I don't want them able to unlock the workbook and make any undesired changes. I want them to be allowed insert or delete rows and input data in unlocked cell. I want the sheet to be locked all the time and only when people want to insert or delete a row it be unlocked and be locked again after inserting or deleting whit no need to insert password in this case only.
View 1 Replies
View Related
Mar 23, 2014
I got a table, some columns are variable data you have to put in by your own and I got some columns with only formulas. After entered the last variable data I want excel to add a new row with the same formulas and format as the other rows in the table.
View 2 Replies
View Related
Apr 9, 2009
I currently have a 200 row table spanning 10 columns. There is one numeric column and the rest are free text. The table charts the different contents on one of the shared drives here at work. The drive is frequently in use with things being added and removed from it.
I have an excel table already which can sort the contents in order of size (numeric row) or name of the folder (the first text column). I have two buttons at the top.
The first inserts a row, which I did by recording a macro and then copying the code into the button.
The second I would like to do the following: When a user selects a cell in a row, the button, then clicked, deletes the entire row. Not just the data in it, but excises the row itself and stitches the surrounding materials together. The code to delete a row I could obtain easily, but I can't work out to say "find the selected cell, and take out the row it belongs to".
View 2 Replies
View Related
Jan 27, 2010
I'm trying to create a macro that will allow me to insert two rows to extend two separate tables. The problem is that one table needs to be directly below the other. So if the number of additional rows exceeds the margin between the two tables, the macro will just be inserting two rows into the top table.
I guess I'm looking for a way to get the macro to insert a row, not at a specific row number, but at the first row of the bottom table, which will change as rows are added to the top table.
View 3 Replies
View Related
Dec 18, 2008
I want to insert a frequency column in my pivot table. See frequency.jpg for an example.
The column has to count the number of times "artikel" is represented in the pivot. Is it possible to do this in a pivot table, and if so, how?
View 9 Replies
View Related
Jun 7, 2013
I need a Module that allowed me when I run it to add Rows down according upper cells Value for Example;
Total
Names
2
Sami
5
Rami
Then after apply the Module I need like this;
Total
Names
2
Sami
[Code] ............
View 4 Replies
View Related
Mar 27, 2008
I currently have a spreadsheet with 4 columns that represent Surface corridinates and Bottom Hole Corridnates.
Surface X, Surface Y, BH X, BH Y
We need to get the Bottom Hole XY to be directly under the Surface XY.
Attached is some sample Data and What I mocked up for a temp solution is in VBA Module2
RunAll it will complete 399 rows of data.
In Module1 I have the starting Code that I modeled off of a macro that I started to get the base code.
I just need this to loop till it has no more data to copy. and not use module2 at all.
I commented everything for my personal benifit and to help me understand the steps. also know its a monster right now but it does most of what I need it to do.
Sub CopyPasteBHXYs()
'Wrote Based on recorded macro
'Selects second data row and inserts a row above
Rows("4:4").Select
Selection.Insert Shift:=xlDown
'How to make it loop till the last data is reached?
End Sub
Side Note I'm finally taking a Excel VBA course Apr 8th and 9th.
View 5 Replies
View Related
Jul 5, 2012
I have a table refreshed from a MySQL database that I use to create a report. I can use this data quite well using formulas in the cells.But in order for me to add more information to the report I use without making it cluttered I need to add some data as comments.
I have created a loop that picks up some cell values that I want to use as criteria but I cant work out how to use these variables to search through the table and get the info I require to put in the comment. In a cell I would use offset/match or index/match to get the required cell value but how do I do this in VBA?
View 2 Replies
View Related
Jan 3, 2013
I decided to format my data as a table so that excel will auto-fill my formulas when inserting new rows which works quite well. I have one snag though, when trying to insert a new row at the very top (i.e. inbetween the header and first row) and choosing Format As Below, it also applies Data Validation and Conditional Formatting to the header. The inserted row, however, is actually formatted fine and works well.
How do I stop this from happening, and why would Excel do this anyway (as it is effectively applying formatting to TWO rows when only one row is being inserted)?
View 3 Replies
View Related
Aug 30, 2013
I'm using excel 2010 and I need a command button to add rows to the end of the dynamic table.
View 3 Replies
View Related