I have a machine that I am trying to connect to using the following code. I don't have admin rights on the box, however the account wsservice does. I am using this account in the code to make the connection.
Result: If I have a drive mapped to the machine with the account wsservice then the code functions just fine. If I don't have a drive mapping it doesn't work and gives me an error. How can I fix this. Thanks.
Public Sub Test()
Dim arrarray
Dim Path As String
arrarray = Array("ppalab005", "plabbank01", "plabbank02", "plbcl03")
For j = LBound(arrarray) To UBound(arrarray)
Path = "\\" & arrarray(j) & "\c$\Test\Test_db1.mdb;"
Dim objConn As New Connection
objConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=" & Path & _
"Uid=wsservice;" & _
"Pwd=*********"
Dim objRS As New Recordset
objRS.Open "Insert_Errors", objConn, , adLockOptimistic, adCmdTable
objRS.AddNew
objRS!MRN = Form_frmManualEntry.txtMRN
objRS!Name = Form_frmManualEntry.txtName
objRS!Birth = Form_frmManualEntry.txtBirth
objRS!ABO_Rh = Form_frmManualEntry.txtABO_Rh
objRS!Phenotype = Form_frmManualEntry.txtPhenotype
objRS!TransReqs = Form_frmManualEntry.txtTransReqs
objRS!Antibodies = Form_frmManualEntry.txtAntibodies
objRS!Antigens = Form_frmManualEntry.txtAntigens
objRS!Comments = Form_frmManualEntry.txtComments
objRS.Update
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
Next
End Sub
Result: If I have a drive mapped to the machine with the account wsservice then the code functions just fine. If I don't have a drive mapping it doesn't work and gives me an error. How can I fix this. Thanks.
Public Sub Test()
Dim arrarray
Dim Path As String
arrarray = Array("ppalab005", "plabbank01", "plabbank02", "plbcl03")
For j = LBound(arrarray) To UBound(arrarray)
Path = "\\" & arrarray(j) & "\c$\Test\Test_db1.mdb;"
Dim objConn As New Connection
objConn.Open "Driver={Microsoft Access Driver (*.mdb)};" & _
"Dbq=" & Path & _
"Uid=wsservice;" & _
"Pwd=*********"
Dim objRS As New Recordset
objRS.Open "Insert_Errors", objConn, , adLockOptimistic, adCmdTable
objRS.AddNew
objRS!MRN = Form_frmManualEntry.txtMRN
objRS!Name = Form_frmManualEntry.txtName
objRS!Birth = Form_frmManualEntry.txtBirth
objRS!ABO_Rh = Form_frmManualEntry.txtABO_Rh
objRS!Phenotype = Form_frmManualEntry.txtPhenotype
objRS!TransReqs = Form_frmManualEntry.txtTransReqs
objRS!Antibodies = Form_frmManualEntry.txtAntibodies
objRS!Antigens = Form_frmManualEntry.txtAntigens
objRS!Comments = Form_frmManualEntry.txtComments
objRS.Update
objRS.Close
Set objRS = Nothing
objConn.Close
Set objConn = Nothing
Next
End Sub