Hi Everyone.
I have a subform within a form. In the form there's a command that deletes fields from the table (tblTable) on which the subform is based.
The command deletes fields from tblTable by executing the sub:
The SQL code can only be executed when the table which it is executed upon isn't in use in the time of execution.
So I rewrote the sub and now it is:
Still, I get the following error during the execution of the SQL:
"Run-time error '3211': The database engine could not lock 'tblTable' because it is already used by another person or process"
Somehow tblTable isn't being set free during the execution of the sub.
Running the sub again, after the SourceObject property is already "", the SQL code gets executed succesfully.
Is there a way to set free tblTable on the first run?
Thanks very much for your time,
inso18
I have a subform within a form. In the form there's a command that deletes fields from the table (tblTable) on which the subform is based.
The command deletes fields from tblTable by executing the sub:
Code:
Sub Delete1()
DoCmd.RunSQL "ALTER TABLE tblTable DROP COLUMN Field1"
End Sub
The SQL code can only be executed when the table which it is executed upon isn't in use in the time of execution.
So I rewrote the sub and now it is:
Code:
Sub Delete1()
'first I'm setting free Table1:
Forms.frmMain.sfrmSubForm.SourceObject = ""
DoEvents
'then I execute the SQL code
DoCmd.RunSQL "ALTER TABLE tblTable DROP COLUMN Field1"
End Sub
Still, I get the following error during the execution of the SQL:
"Run-time error '3211': The database engine could not lock 'tblTable' because it is already used by another person or process"
Somehow tblTable isn't being set free during the execution of the sub.
Running the sub again, after the SourceObject property is already "", the SQL code gets executed succesfully.
Is there a way to set free tblTable on the first run?
Thanks very much for your time,
inso18