G
Guest
Thanks to help I found in this forum, I created some VB code that appends
data from one subform to a table within another subform when I click on the
"Save" button. This code works wonderfully.
The problem I'm having is, after this code creates this table, I'm trying to
run a different query that creates another table using the data that is in
the first table I created.
I'm getting an error - Run-time error: '3211' The database engine could
not lock table 'tbl_High_Vol_Disc' because it is already in use by another
person or process.
Here's the code:
Dim strSQL As String
Dim stDocName As String
Dim RsC As DAO.Recordset
Set RsC = Me.RecordsetClone
RsC.MoveFirst
While Not RsC.EOF
Me.Bookmark = RsC.Bookmark
If Chk_Add = -1 Then
strSQL = "INSERT INTO [tbl_PVD_Updates](AcctNo, ItemNo,
ProjectNo,
[Date], Charge_Units, Unitpr, Rprice)" & _
"select" & "'" & txt_AcctNo & "'," & "'" & txt_ItemNo & "',"
& "'" &
txt_ProjectNo & "'," & "'" & _
txt_Date & "'," & "'" & [txt_Actual Units] &
"'," & "'" & txt_Unitpr
& "'," & "'" & txt_rprice & "';"
DBEngine(0)(0).Execute strSQL, dbFailOnError
End If
RsC.MoveNext
Wend
Set RsC = Nothing
'Works great up to here.
stDocName = "qry_PVD_Discounts" 'Code stops working here.
'Uses "tbl_PVD_Updates" to create new table,
"tbl_High_Vol_Disc".
DoCmd.OpenQuery stDocName, acNormal, acEdit
[Forms]![frm_PVD]![frm_PVD_Import].Requery
[Forms]![frm_PVD]![frm_High_Vol_Disc].Requery
Me.Refresh
I hope I explained this clearly enough. Any help would be greatly
appreciated.
Thanks,
Rachel
data from one subform to a table within another subform when I click on the
"Save" button. This code works wonderfully.
The problem I'm having is, after this code creates this table, I'm trying to
run a different query that creates another table using the data that is in
the first table I created.
I'm getting an error - Run-time error: '3211' The database engine could
not lock table 'tbl_High_Vol_Disc' because it is already in use by another
person or process.
Here's the code:
Dim strSQL As String
Dim stDocName As String
Dim RsC As DAO.Recordset
Set RsC = Me.RecordsetClone
RsC.MoveFirst
While Not RsC.EOF
Me.Bookmark = RsC.Bookmark
If Chk_Add = -1 Then
strSQL = "INSERT INTO [tbl_PVD_Updates](AcctNo, ItemNo,
ProjectNo,
[Date], Charge_Units, Unitpr, Rprice)" & _
"select" & "'" & txt_AcctNo & "'," & "'" & txt_ItemNo & "',"
& "'" &
txt_ProjectNo & "'," & "'" & _
txt_Date & "'," & "'" & [txt_Actual Units] &
"'," & "'" & txt_Unitpr
& "'," & "'" & txt_rprice & "';"
DBEngine(0)(0).Execute strSQL, dbFailOnError
End If
RsC.MoveNext
Wend
Set RsC = Nothing
'Works great up to here.
stDocName = "qry_PVD_Discounts" 'Code stops working here.
'Uses "tbl_PVD_Updates" to create new table,
"tbl_High_Vol_Disc".
DoCmd.OpenQuery stDocName, acNormal, acEdit
[Forms]![frm_PVD]![frm_PVD_Import].Requery
[Forms]![frm_PVD]![frm_High_Vol_Disc].Requery
Me.Refresh
I hope I explained this clearly enough. Any help would be greatly
appreciated.
Thanks,
Rachel