Excel to Access: trouble with Memo data type

The_Kurgan

Active Member
Joined
Jan 10, 2006
Messages
270
Hi all.

I am automating the inserting of data from Excel to an Access table. The problem that I'm running into is one field containing a large string (up to several sentences). The maximum number of characters is 500. Everything inserts (transfers) fine except for that one field which ends-up being empty in Access. I've tried switching the data type in the Access table to Memo, but still no dice. I can copy/paste the data with no issues... it's just something in the automation. I've tried two different methods with the same results:

METHOD 1:
Code:
Public Sub TRANStest2()
Dim cn As New ADODB.Connection
Dim stDB As String, stSQL As String, stProvider As String
Dim strSQL1 As String
stDB = "[URL="file://\\fimcfs001\CORP\Accounting-Shared\Reporting"]\\fimcfs001\CORP\Accounting-Shared\Reporting[/URL] Team\Reporting and Analytics Tool\Access\xxx.accdb"
stProvider = "Microsoft.ACE.OLEDB.12.0"
dbWb = Application.ActiveWorkbook.FullName
dsh = "[" & Application.ActiveSheet.Name & "$]"
'Opening connection to database
With cn
    .ConnectionString = stDB
    .Provider = stProvider
    .Open
End With
'Create the Recordset object
Set rs = New ADODB.Recordset
rs.CursorLocation = adUseClient
strSQL = "INSERT INTO Assigned_Data ([Done], [Suspense_Notes], [Branch], [Prod_Code)"
strSQL = strSQL & "SELECT * FROM [Excel 8.0;HDR=YES;DATABASE=" & dbWb & "]." & dsh
rs.Open strSQL, cn, adOpenStatic, adLockBatchOptimistic
'Close everything
cn.Close
Set cn = Nothing
Set rs = Nothing
End Sub


METHOD 2:
Code:
Set AccessApp = CreateObject("Access.Application")
AccessApp.OpenCurrentDatabase "[URL="file://\\fimcfs001\CORP\Accounting-Shared\Reporting"]\\fimcfs001\CORP\Accounting-Shared\Reporting[/URL] Team\Reporting and Analytics Tool\Access\xxx.accdb"
AccessApp.DoCmd.TransferSpreadsheet TransferType:=acImport, _
        SpreadSheetType:=acSpreadsheetTypeExcel12Xml, TableName:="Assigned_Data", Filename:=Application.ActiveWorkbook.FullName, HasFieldNames:=True, Range:="ERDB Data$A1:AJ" & cnt
AccessApp.CloseCurrentDatabase
AccessApp.Quit
Set AccessApp = Nothing


Any ideas would be greatly appreciated!
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Bump

I'm also seeing that the list of ImportErrors shows "Type Conversion Failure" for each record. How can that be if I'm plugging into a Memo field?
 
Upvote 0
Ok, never mind. I created a work-around.

I found that if I create a dummy record with a simple string in that field (something like "abc123") AND make that the first record to be imported, Access then accepts all subsequent records with that field fully in tact. I can then programmatically go in after the fact and delete the dummy record. It seems silly to have to jump through those hoops, but hey... it works.
 
Upvote 0

Forum statistics

Threads
1,215,343
Messages
6,124,400
Members
449,156
Latest member
LSchleppi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top