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

Runtime 3211 - Locking problem

Status
Not open for further replies.

AllanBertelsen

Programmer
Mar 14, 2007
8
DK
I need to delete a field from a table via VBA.

To close the table, so it can be altered, I load a form without a record source. The code for this form goes like this:

Private Sub Form_Load()
Dim strFelt As String
strFelt = Me.OpenArgs
DoCmd.Close acForm, "Adresser", acSaveYes 'Has the table as source
DoCmd.SetWarnings False
DoCmd.RunSQL "alter table Brugertabel drop column [" & strFelt & "]"
DoCmd.SetWarnings True
DoCmd.Close acForm, Me.Name
DoCmd.OpenForm "Adresser"
End Sub

The "ALTER TABLE" statement results in a runtime 3211 dispite this form is the only one that is open. If I copy the SQL-statement to the immediate window, reset code execution and run the SQL-statement from the immediate window - the field is dropped without further notification.

NB - I'm so sory
I did post this in the wrong forum. I'm new - and hope that i'm not going to be excluded by this double posting.
 
I found an answer.

In the Form_Load event, the locks has not been released. By tranfering the code to the timer-event everything is working just fine.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top