Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Can't Update. Database or Object is locked."?

Status
Not open for further replies.

tbellomo

Technical User
Jan 28, 2002
73
US
Hey all,
I'm trying to open a recordset and write to it. I've done it a million times, but this time, I'm getting an odd error (see subject). Here is the code:
-----------------------------
Dim db As Database
Dim rs As Recordset
Dim SQL As String

lngLoan = Me.Acct_

SQL = "SELECT tblAuditFile.InvestorName, tblAuditFile.AuditDate, tblAuditFile.AuditMonth, tblAuditFile.AuditYear, tblAuditFile.[Acct#], tblAuditFile.bool1, tblAuditFile.bool2, tblAuditFile.bool3, tblAuditFile.bool4, tblAuditFile.bool5, tblAuditFile.bool6, tblAuditFile.bool7, tblAuditFile.bool8, tblAuditFile.bool9, tblAuditFile.bool10, tblAuditFile.ViolationCount " & _
"FROM tblAuditFile " & _
"WHERE (((tblAuditFile.InvestorName)= ' & strInvestor & ') AND ((tblAuditFile.AuditMonth)= ' & strMonth & ') AND ((tblAuditFile.AuditYear)= ' & strYear & ') AND ((tblAuditFile.[Acct#])= " & lngLoan & "));"

Set db = DBEngine(0)(0)
Set rs = db.OpenRecordset(SQL)

If rs.EOF And rs.BOF Then
rs.AddNew
rs(0) = strInvestor
rs(1) = date
rs(2) = strMonth
rs(3) = strYear
rs(4) = lngLoan
rs(5) = Me.Check1
rs(6) = Me.Check2
rs(7) = Me.Check3
rs(8) = Me.Check4
rs(9) = Me.Check5
rs(10) = Me.Check6
rs(11) = Me.Check7
rs(12) = Me.Check8
rs(13) = Me.Check9
rs(14) = Me.Check10
rs(15) = LoanVCount
Else
rs.Edit
rs(5) = Me.Check1
rs(6) = Me.Check2
rs(7) = Me.Check3
rs(8) = Me.Check4
rs(9) = Me.Check5
rs(10) = Me.Check6
rs(11) = Me.Check7
rs(12) = Me.Check8
rs(13) = Me.Check9
rs(14) = Me.Check10
rs(15) = LoanVCount
End If
rs.Update

rs.Close
db.Close
-------------------------
It errs on the "rs.AddNew"

can anybody see why?

Thanks,
Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top