Dear All,
I have a problem appending my Excel data into our database that is stored in our server. When I hit the command
button on my Excel sheet, I get this error:
Run-time error '3033':
You do not have the necessary permissions to use the
'H:\206_PDDM\TDC_DB\TDCSK.mdb' object. Have your system
administrator or the person who created this object establish the
appropriate permissions for you.
If I press OK, the debugger stops at this line highlighted in yellow:
Please note that the folder is mapped as "H" drive.
Here's the code behind my Excel command button:
Your help is higly appreciated.
Thank you & Regards,
qwerty70
I have a problem appending my Excel data into our database that is stored in our server. When I hit the command
button on my Excel sheet, I get this error:
Run-time error '3033':
You do not have the necessary permissions to use the
'H:\206_PDDM\TDC_DB\TDCSK.mdb' object. Have your system
administrator or the person who created this object establish the
appropriate permissions for you.
If I press OK, the debugger stops at this line highlighted in yellow:
Code:
Set db = OpenDatabase("H:\206_PDDM\TDC_DB\TDCSK.mdb")
Please note that the folder is mapped as "H" drive.
Here's the code behind my Excel command button:
Code:
Private Sub CommandButton1_Click()
Dim db As Database
Dim rs As Recordset
Dim XLTable As TableDef
Dim strSQL As String
Dim Msg, Style, Title, Help, Ctxt, Response
Msg = "Do you want to continue?" & vbCrLf & _
"If Yes, the data will be added" & vbCrLf & _
"in the TDC database and you cannot" & vbCrLf & _
"undo the data transfer."
Style = vbYesNo + vbInformation + vbDefaultButton2
Title = "Upload data into TDC system"
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then ' User chose Yes.
'Open the Microsoft Access database.
Set db = OpenDatabase("H:\206_PDDM\TDC_DB\TDCSK.mdb")
'Attach the Microsoft Excel 5.0 table "MyTable" from the file
'Book1.xls to the Microsoft Access database.
Set XLTable = db.CreateTableDef("Temp")
XLTable.Connect = "Excel 5.0;DATABASE=D:\Book1.xls"
XLTable.SourceTableName = "MyTable"
db.TableDefs.Append XLTable
'Run the append query that adds all of the records from MyTable
'to the tblCalcSht table.
strSQL = "Insert into tblOC_CalcSht Select * from Temp"
'Execute the SQL statement.
db.Execute strSQL
'Remove the attached table because it's no longer needed.
db.TableDefs.Delete "Temp"
db.Close
Else ' User chose No.
Cancel = True
End If
End Sub
Your help is higly appreciated.
Thank you & Regards,
qwerty70