Upadting QueryTable in access 2010 using vba code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • akjandu
    New Member
    • Oct 2013
    • 2

    Upadting QueryTable in access 2010 using vba code

    Hi,

    I have a querytable in my database and I want to update the querytable using VBA code. I am confused with how to connect to the querytable and basically refresh it.

    Thanks in advance.
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    akjandu:
    Queries are not Tables. They are a view of an underlying table. Anything that you do in the table, or in the query, will normally alter the table. The query will reflect that once it is re-ran. MS Access 2010 Tutorials

    If you have a form based on a query, then the changes made by the user in the form happen IRL. If you have made changes via code, or if in a multi-user environment, you may need to issue a "requery" - this can be done in a few ways such as the DoCmd.Requery or (the way I tend to do this) is the control.requery so in a form I would use me.requery

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      I believe they may be talking about an Excel QueryTable. The Excel QueryTable object has a refresh method.

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        Rabbit you may very well be correct (and usually are (^-^))
        however:
        I have a querytable in my database and I want
        Was what I based my reply on.
        In either case, as you noted or as I was attempting to point out, the refresh/requiry method will update the query results.

        Comment

        • akjandu
          New Member
          • Oct 2013
          • 2

          #5
          Thanks. Your method worked.
          Originally posted by zmbd
          akjandu:
          Queries are not Tables. They are a view of an underlying table. Anything that you do in the table, or in the query, will normally alter the table. The query will reflect that once it is re-ran. MS Access 2010 Tutorials

          If you have a form based on a query, then the changes made by the user in the form happen IRL. If you have made changes via code, or if in a multi-user environment, you may need to issue a "requery" - this can be done in a few ways such as the DoCmd.Requery or (the way I tend to do this) is the control.requery so in a form I would use me.requery

          Comment

          Working...