How do I copy data from a cell in excel onto a field in a table in access db using vba

Codeeachday

New Member
Joined
Jan 29, 2013
Messages
1
So I am trying to type data into cell B9535 in excel and use an ActiveX submit button to have this data appended to a table called 'tblImport' in Access to the Field called 'SalesOrderID'
here is the code:
Private Sub Submit_Click()
Dim dbConn
Set dbConn = CreateObject("ADODB.Connection")
With dbConn
.Provider = "Microsoft.ACE.OLEDB.12.0"
.Open "db path here"
End With
End Sub
Private Function InsertRecord()
Dim strSQL As String
strSQL = "Insert INTO tblImport(SalesOrderID) VALUES ('=Range" 'B''9535'"')"
dbConn.Execute strSQL
End Function
Private Sub Form_Terminate()
dbConn.Close
Set dbConn = Nothing
End Sub
There are no errors when I compile but nothing happens.
no data is appended onto the access table.
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,215,978
Messages
6,128,057
Members
449,416
Latest member
SHIVANISHARMA1711

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