InFlight
User
- Local time
- Tomorrow, 07:33
- Joined
- Jun 11, 2015
- Messages
- 130
Hi
I am getting this error on this code. it happens on the CurrentDb.Execute
Error 3211 (The database engine could not lock table 'tbl_Names'
because it is already in use by another person or process)
I am getting this error on this code. it happens on the CurrentDb.Execute
Error 3211 (The database engine could not lock table 'tbl_Names'
because it is already in use by another person or process)
Code:
Private Sub P2_Combo_NotInList(NewData As String, Response As Integer)
On Error GoTo P2_Combo_NotInList_Error
Dim oRS_P2 As DAO.Recordset, i As Integer, sMsg As String
Response = acDataErrContinue
If MsgBox("Name is not in list. Add it?", vbYesNo) = vbYes Then
i = DMax("[ID]", "tbl_Names") + 1
Set oRS_P2 = CurrentDb.OpenRecordset("tbl_Names", dbOpenDynaset)
oRS_P2.AddNew
oRS_P2.Fields(0) = i
oRS_P2.Fields(1) = NewData
oRS_P2.Update
oRS_P2.Close
Set oRS_P2 = Nothing
P2_Combo = i
P2_Combo.Requery
CurrentDb.Execute " ALTER TABLE tbl_Names ADD COLUMN " & NewData & " Long", dbFailOnError
End If
On Error GoTo 0
Exit Sub
P2_Combo_NotInList_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure P2_Combo_NotInList, line " & Erl & "."
End Sub