I am trying to create a new table using a macro however everything i run the function it tells me that the table can't be locked because it is already in use. I added a command to close the form the macro is launched from because the table is used on that form but I still get the same error.
I am creating the table using do.cmd RunSQL
This is the function I am using to create the new table;
Any ideas on how I can get around this?
I am creating the table using do.cmd RunSQL
This is the function I am using to create the new table;
Code:
Function CreateTable()
DoCmd.SetWarnings False
DoCmd.RunSQL "SELECT qryTotalPartsUsed.PartNumber, qryTotalPartsUsed.Ordered INTO tblOnOrder FROM qryTotalPartsUsed"
DoCmd.RunSQL "CREATE INDEX PartNumber ON tblOnOrder(PartNumber) With Primary"
DoCmd.SetWarnings True
End Function
Any ideas on how I can get around this?