Results 1 to 2 of 2

Thread: Modify Query

  1. #1
    Join Date
    Sep 2005

    Unanswered: Modify Query

    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.

  2. #2
    Join Date
    Mar 2006
    Wouldn't this actually open the query?
    Set cmd = cat.Views("Statement Informations").Command

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts