modify query

J

Jacky

Dim strSQL As String

strSQL = "SELECT [Company Name],[Vendor Name],[Account],[Statement
Number],[Amount] from [Statements] "

Dim cat As New ADOX.Catalog
Dim cmd As New ADODB.Command
Dim qry As ADOX.view
cat.ActiveConnection = CurrentProject.Connection
Set cmd = cat.Views("Statement Informations").Command
cmd.CommandText = strSQL
Set cat.Views("Statement Informations").Command = cmd

Set cat = Nothing
DoCmd.OpenQuery "Statement Informations"


I used the above code to modify the existing query, "Statement Informations".

When I run it, it give out the error message:

Run-time error '3218':
Could not update; currently locked.

And then, I went to queries section, and open the query "Statement
Informations" directly, close the query, and then run the code again.
Then, it works.

I don't know why.
If I run it on next machine on other day, then it give out same error.

How can I solve it?
Please let me know, thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top