Not an expert so I need some help. I have this function that I am trying to run. The function is to compine two tables, comcare a field in the tables and update the one table if te fields are not equal. I am getting the Run-Time error 3027 Can not update. The database or object is read only. I know for sure that the database is not read only because I am able to edit the tables within other forms and modules. I believe that it might have something to do with the import command but do not understand how...
Function ImportBMList()
Dim thisdb As DAO.Database
Dim rsBranch As DAO.Recordset
Dim BM_RosterName As String
Dim strModDate As String
Dim mmddyyyy As Date
DoCmd.SetWarnin gs False
Set thisdb = CurrentDb
strModDate = Format(Date, "mm" & "/" & "dd" & "/" & "yyyy")
thisdb.Execute ("Delete * From BM_Roster")
DoCmd.TransferT ext acImportDelim, "BMImport", "BM_ROSTER" , "C:\tbl_roster_ SPA_BM.txt"
Set rsBranch = thisdb.OpenReco rdset("Select * From Branch,BM_ROSTE R Where Branch.StateBra nch = BM_ROSTER.sapNo ", dbOpenDynaset)
Do Until rsBranch.EOF
If rsBranch.Fields ("MName") = " " Then
BM_RosterName = rsBranch.Fields ("Fname") & " " & rsBranch.Fields ("LName")
Else
BM_RosterName = rsBranch.Fields ("Fname") & " " & rsBranch.Fields ("MName") & " " & rsBranch.Fields ("LName")
End If
If rsBranch.Fields ("BranchManager ") = BM_RosterName Then
'do nothing
Else
rsBranch.Edit
rsBranch.Fields ("BranchManager ") = BM_RosterName
rsBranch.Fields ("BranchManFNam e") = rsBMList.Fields ("Fname")
rsBranch.Fields ("BranchManLNam e") = rsBMList.Fields ("Lname")
rsBranch.Fields ("Modified") = True
rsBranch.Fields ("DateModified" ) = strModDate
rsBranch.Update
End If
rsBranch.MoveNe xt
rsBMList.MoveNe xt
Loop
rsBranch.Close
Set rsBranch = Nothing
MsgBox "Branch Manager Roster Imported.", , "Citizens Hierarchy"
End Function
Function ImportBMList()
Dim thisdb As DAO.Database
Dim rsBranch As DAO.Recordset
Dim BM_RosterName As String
Dim strModDate As String
Dim mmddyyyy As Date
DoCmd.SetWarnin gs False
Set thisdb = CurrentDb
strModDate = Format(Date, "mm" & "/" & "dd" & "/" & "yyyy")
thisdb.Execute ("Delete * From BM_Roster")
DoCmd.TransferT ext acImportDelim, "BMImport", "BM_ROSTER" , "C:\tbl_roster_ SPA_BM.txt"
Set rsBranch = thisdb.OpenReco rdset("Select * From Branch,BM_ROSTE R Where Branch.StateBra nch = BM_ROSTER.sapNo ", dbOpenDynaset)
Do Until rsBranch.EOF
If rsBranch.Fields ("MName") = " " Then
BM_RosterName = rsBranch.Fields ("Fname") & " " & rsBranch.Fields ("LName")
Else
BM_RosterName = rsBranch.Fields ("Fname") & " " & rsBranch.Fields ("MName") & " " & rsBranch.Fields ("LName")
End If
If rsBranch.Fields ("BranchManager ") = BM_RosterName Then
'do nothing
Else
rsBranch.Edit
rsBranch.Fields ("BranchManager ") = BM_RosterName
rsBranch.Fields ("BranchManFNam e") = rsBMList.Fields ("Fname")
rsBranch.Fields ("BranchManLNam e") = rsBMList.Fields ("Lname")
rsBranch.Fields ("Modified") = True
rsBranch.Fields ("DateModified" ) = strModDate
rsBranch.Update
End If
rsBranch.MoveNe xt
rsBMList.MoveNe xt
Loop
rsBranch.Close
Set rsBranch = Nothing
MsgBox "Branch Manager Roster Imported.", , "Citizens Hierarchy"
End Function
Comment