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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

edit record - currently locked ?

Status
Not open for further replies.

ooops

MIS
Dec 21, 2000
91
US
Hi,
I have a form for users to enter data and save it to table. Before saving, it should check if the record for the same ID & year already exist. If it is then just edit record. I got problem with this part. The msg I got is : "Could not update; currently locked by another session on this machine." Please help me to fix it. Thanks.



Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
strSQL = "SELECT * FROM myTable WHERE ID = " & Chr(34) & Me![txtID] & Chr(34) & _
" AND Year = " & Chr(34) & Me![txtYear] & Chr(34)

Set db = CurrentDb
Set rs = db.OpenRecordset(strSQL)

With rs
If .BOF And .EOF Then
Me.AllowEdits = True
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Else
rs.Edit
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
'MsgBox "The record entered is already exist."
rs.Close
Set rs = Nothing
Exit Sub
End If
End With

rs.Close
Set rs = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top