I am trying to import data from a linked Excel file, but when it was exported from the Supplier in CSV/XLSX format any data in the Description column that was longer than 35 characters it would be inserted to the next cell below showing up as a separate record in the Access Table.
How do I Join them together the description back together?
7 1025 zmbd 5,501
Expert Mod 4TB
+ Is the field length setting for the [Description] field in the access table large enough to hold the extra data?
+ As this is a CSV file, it could be possible to open the file for I/O and parse thru it first using VBA removing the return at the end of the prior line.... Without the data, it's hard to provide more than pseudo code/logic
+ Would you be so kind as to enter the example data (just four rows should do :) ) as a table within a post? Use the [CODE/] format to hold the formatting and the <Space>s instead of <Tab>s for column formatting.
++ Many of our experts (I am one such) are not able to d/l unrequested attachments due to various IT-Security policies and/or firewall restrictions.
+ Information on the table design would also be most helpful.
[TableName]
[TableName]![FieldName] datatype (ie Autonumber, Text(25), etc) PK=Primary Key, FK = Foreign Key
-z
The Raw Data is in Excel. It is already separated. I don't have code to rejoin the Description.
I was thinking something like NextRecord(if(isNull([Column1]),([Column2] & NextRecord [Column2]).
Received data to import:
Column1---Column2
1881074---ZURN QQPC44X 3/4 BARB PEX POLY CPLG
3055338---SPECPROD P-1066 PIPE SUPPORT
----------BRACKET 2IN X 20IN W/EXTRA 1/2IN
----------HOLE 1/2INON 1IN CENTERS 3/4IN ON
----------4IN CENTERS
Data needs to be like after import:
Column1---Column2
1881074---ZURN QQPC44X 3/4 BARB PEX POLY CPLG
3055338---SPECPROD P-1066 PIPE SUPPORT BRACKET 2IN X 20IN W/EXTRA 1/2IN HOLE 1/2INON 1IN CENTERS 3/4IN ON 4IN CENTERS
- 1637710 zurn q4ps20x 3/4x20 straight length
-
pex hot/cold wht tube
-
1881074 zurn qqpc44x 3/4 barb pex poly cplg
-
3055338 specprod p-1066 pipe support
-
bracket 2in x 20in w/extra 1/2in
-
hole 1/2inon 1in centers 3/4in on
-
4in centers
-
If I were doing this, I would stitch the Description back together when Importing the Spreadsheet instead of attempting to fix it later. It's usually easier that way.
I took something that I had that was sort of similar and tweaked it to work with your data. Here is the result: - Private Sub Command0_Click()
-
On Error GoTo ErrorOut
-
-
Dim sSpreadsheet As String
-
Dim oExcel As Excel.Application
-
Dim oWorkbook As Excel.Workbook
-
Dim oSheets As Excel.Sheets
-
Dim oSheet As Excel.Worksheet
-
-
Dim lCount As Long
-
Dim sSQL As String
-
Dim sColumn1 As String
-
Dim sColumn2 As String
-
Dim sDescription As String
-
-
' Open the Spreadsheet
-
sSpreadsheet = "C:\Users\Desktop\Bytes\SampleData.xlsx"
-
Set oExcel = New Excel.Application
-
Set oWorkbook = oExcel.Workbooks.Open(sSpreadsheet, ReadOnly:=True)
-
Set oSheets = oWorkbook.Sheets
-
Set oSheet = oWorkbook.Sheets(1)
-
For lCount = 1 To oSheet.Rows.Count
-
-
' get Columns
-
sColumn1 = oSheet.Cells(lCount, 1).Value
-
sColumn2 = oSheet.Cells(lCount, 2).Value
-
-
' Test for New Row
-
If Len(sColumn1) > 0 Then
-
-
' Insert Previous Row, if there is one
-
If Len(sSQL) > 0 Then
-
sSQL = sSQL & sDescription & "')"
-
CurrentDb.Execute (sSQL)
-
End If
-
-
' Build up new Row SQL
-
sSQL = "INSERT INTO ExcelImport ( Column1, Column2) VALUES ( '" & sColumn1 & "', '"
-
sDescription = sColumn2
-
Else
-
-
' Row might Continue, Add additional Description
-
sDescription = sDescription & " " & sColumn2
-
-
' Test for completely blank Row and end of Spreadsheet
-
If Len(sColumn2) = 0 Then
-
If Len(sSQL) > 0 Then
-
' Insert Last Row
-
sSQL = sSQL & sDescription & "')"
-
CurrentDb.Execute (sSQL)
-
End If
-
-
'Exit out of Looping
-
Exit For
-
End If
-
End If
-
-
Next lCount
-
-
MsgBox "Import complete. " & lCount & " rows processed."
-
-
ExitOut:
-
'Clean up and release the Spreadsheet if it is opened
-
If Not oWorkbook Is Nothing Then
-
oWorkbook.Close SaveChanges:=False
-
Set oWorkbook = Nothing
-
End If
-
If Not oExcel Is Nothing Then
-
oExcel.Quit
-
Set oExcel = Nothing
-
End If
-
Exit Sub
-
-
ErrorOut:
-
MsgBox (Err.Description)
-
Resume ExitOut
-
End Sub
You'll need to play around with it and make it yours, but I think that should get you going in the right direction. You'll also need to add a reference to the Excel object library in the Visual Basic IDE.
jforbes reading your code I believe that you have the solution to my problem. New problem is that I am not that proficient in SQL/VBA. Is there a MS Access solution?
Thanks for the code, I will try to stumble though VBA to see if I can get the code to work.
NeoPa 32,556
Expert Mod 16PB Hat2Boots:
New problem is that I am not that proficient in SQL/VBA. Is there a MS Access solution?
They're all part of Access to be fair, but certainly SQL, and then VBA, are increasingly complex areas of the whole product. It's usual to start with the basics then move on to working with the SQL directly and then, later still, to get more into the VBA side of things.
Unfortunately for you, in this particular instance, what you need requires VBA and SQL. I see no way to accomplish it without.
I agree with NeoPa, there is not a native point and click solution for your situation that I can think of. One way or another it will involve either SQL, VBA, both SQL and VBA, or manually correcting the data.
...Searching the Internet, there seem to be some third party solutions that might work in Excel to merge the rows before they are imported, but I've not tried any. If you would rather not take the plunge into developing in Access, this may be a solution for you, but this sort of thing usually comes with a dollar value attached to it.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Darren |
last post by:
I have been attempting to create a reservation planning form in excel
that imports Data from an Access database and inserts that information
automaticly into the correct spreed sheet and the...
|
by: Michael Malafronte |
last post by:
Whenever I try to either Link or Import a Sybase or Sql database table
to Access, it freezes.
|
by: farseer |
last post by:
Hi,
i would like to write an app that will do the following:
1. download a csv file from an http url. fields are delimited by the
"|"
2. i would like to import this into an access database...
|
by: freeskier |
last post by:
Hello,
I am looking for some advice on collecting data. We are working on collecting about 20 different data points from 60 initial people, later to be expanded to approximately 200. At present we...
|
by: Milan Mehta |
last post by:
I am new to Access. I have developed an application in Access 2007. I have kept all the tables in a MDB file and all the forms in a seperate accdb file. All the tables of MDF file is link in the...
|
by: MBlock316 |
last post by:
Hello everyone,
I am trying to import a Microsoft Excel 2007 formatted file into my application. I found on another thread in another forum that I needed to install the 2007 Office System Driver:...
|
by: bkberg05 |
last post by:
Hi - I currently use Access 2003 and have documents stored in an OLE data type field. I want be able to write a query that contains various other data elements from the table plus the OLE field and...
|
by: zuraberadze |
last post by:
I can't connect C# to MS Access 2007 to insert data into DB. please help me. it can't see the type of db. thx
|
by: newsco |
last post by:
Dear all,
I use VB6 ADO connect to Access 2007 accdb database, everything is fine except I cannot retrieve image file stored in the Access 2007 attachment data type.
Can anyone show me some vb...
|
by: Elaine Huseby |
last post by:
I have a form "PartsAndInvoices that has all the parts in the database listed in split form view. I want the user to use Access 2007's filter section on the ribbon to choose mutiple filters....
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |