How to copy data from an excel cell into a field in access table

codeeachday

New member
Local time
Yesterday, 21:24
Joined
Jan 27, 2013
Messages
2
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
When I compile the code, there are no errors, nothing is appended in access.
Please help!:confused:
 
Welcome Aboard:)
I'm pretty sure the syntax in the Values() clause is incorrect but I don't do much work with Excel so I'm not positive. You are more likely to get a quick answer in an Excel forum since the question is about Excel VBA. The fact that the database you are trying to update is ACE is probably not even relevant.

I can't move the thread for you so if you repost in the Excel forum, please include a link to this thread and vice versa so people who help can easily see both threads.
 
Thanks. I tried to navigate the website for an excel forum but did not find one. Do you have a link you could share?
 

Users who are viewing this thread

Back
Top Bottom