Transferring Excel Columns to Access Fields

mahmud1180

New Member
Joined
Oct 26, 2015
Messages
17
Hi there!! I want to run a VBA code that makes a column in the excel file and then transfer it to Access with a certain Field Name. Then this excel Column is replaced by another set of Values and I want to transfer it to Access with another Field Name.I have a recurring procedure so, I can not use the AccessImport Method. I can add values cell by cell but I want to avoid that as it is gonna take more time. Can anyone help? Thanks a lot!!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Cross-posted: Transferring Excel Columns to Access Fields

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule #10 here: Forum Rules).

This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.

For a more complete explanation on cross-posting, see here: Excelguru Help Site - A message to forum cross posters).
 
Upvote 0
@ SheetSpread Transfer spread sheet does not work for me. It will work If I can only change the Field name everytime and post the data there without deleting the data transferred previously (which I haven't been able to do)

@Joe4 Sorry for the cross posting. Did not know about the rules about it. I am on the verge of the deadline of a project. So, I was looking for a quick answer from anywhere.
 
Upvote 0
@ Transfer spread sheet does not work for me. It will work If I can only change the Field name everytime and post the data there without deleting the data transferred previously (which I haven't been able to do)

So have the code change the field name (or temporarily change it then back).
 
Upvote 0


I think this may help. I get an error while trying that code though.
Code:
Public Sub DoTrans()



  Set cn = CreateObject("ADODB.Connection")
  dbPath = Application.ActiveWorkbook.Path & "\Database3.accdb"
  dbWb = Application.ActiveWorkbook.FullName
  dbWs = Application.ActiveSheet.Name
  scn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & dbPath
  dsh = "[" & Application.ActiveSheet.Name & "$D5:D5000]"
  cn.Open scn


cn.Execute "ALTER TABLE Test ADD COLUMN Age3 TEXT(25)"


  ssql = "INSERT INTO Test ([Age3]) "
  ssql = ssql & "SELECT * FROM [Excel 12.0;HDR=YES;DATABASE=" & dbWb & "]." & dsh
      
  cn.Execute ssql




End Sub


This is the error: The INSERT into statement contains the following unknown field name: '10000000'. Make sure you have typed the name correctly( Could not post an image here )
 
Last edited:
Upvote 0
Is 10000000 the field name? Exactly?

Check that it's named as such everywhere

Otherwise it could be one of these problems:

FWIW,

I have seen this behaviour a bit with Append queries.
I find that opening the query in Design view, and reselecting the field name on the grid, usually fixes the issue.

Denis
 
Last edited:
Upvote 0
Is 10000000 the field name? Exactly?

Check that it's named as such everywhere

Otherwise it could be one of these problems:

There is no filed name like that. There is nothing with that name.

I tried with the design mode but it still gives the same error :(
 
Upvote 0

Forum statistics

Threads
1,221,834
Messages
6,162,268
Members
451,758
Latest member
lmcquade91

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