Hi, I have created a macro file that will store/upload the data to the database. Users are sitting across the country. I have given a separate folder for each user and kept the macro file. I will explain with a below example.
A is Admin(me). B , C D are the users.
Separate folders in the server location has been created for B, C & D users by Admin.
Folder created for Access database in the server location and B,C & D are have the full access to their respective folders and Access database folder.
User B is updating some entries in the Excel. After updating B needs to click a button to run the macro. Now my macro will push those information to MS Access database.
Here is the problem.
After clicking the button, some times info uploaded to the database.
First Problem : Some time it shows below error and the user input not uploading the data to the database. Instead of I can see come blank rows added in the access database.

Second Problem :
I am using below VBA code to insert the data to my access database.
Sub insert_data(tablename As String, wkb As Workbook, rng As Range)
Application.ScreenUpdating = False
Dim cnn As Object
Dim workbookname As String
Dim sqlstring As String
Dim rngtoinsert As String
Dim dbpath As String
Dim columnnames As String
Dim columncounter As Integer
Set cnn = CreateObject("ADODB.Connection")
dbpath = "\IPAddress\Database\Data_Repository.accdb"
workbookname = wkb.FullName
rngtoinsert = "[" & rng.Parent.Name & "$" & rng.Address(0, 0) & "]"
For columncounter = 1 To rng.Columns.Count
columnnames = columnnames & "[" & rng.Cells(1, columncounter).Value & "],"
Next
columnnames = Left(columnnames, Len(columnnames) - 1)
cnn = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & dbpath
cnn.Open cnn
sqlstring = "INSERT INTO " & tablename & "(" & columnnames & ") "
sqlstring = sqlstring & "SELECT * FROM [Excel 12.0;HDR=YES;DATABASE=" & workbookname & "]." & rngtoinsert
cnn.Execute sqlstring
cnn.Close
End Sub
But when cnn.Execute sqlstringis running the copy of the same Macro workbook is opening as read-only.
I am not sure both the problem are coming for one reason.
I am using office 365 including MS Access package.
Can anyone help me out?
Regards,
Lokesh