I usually dont have many issues in access but can't seem to remember how to do this for the life of me. I have tables that are added to the database monthly with the exact same column headers and the name of the table only differs by the period. For example one table would be "200901 Rev" and another would be "200902 Rev". I'm looking to make a query to pull the same information from each table but need to run it for multiple periods...for example 200901-200906. Any help would be greatly appreciated. Thanks!
There may be a better way, but this will do it:
I can't think of a way to pass a table to a query as a parameter for that query.Sub Lewis2010() Dim strTable As String Dim strQ1 As String Dim strQ2 As String Dim lng As Long strTable = " Rev" strQ1 = "SELECT * FROM [" strQ2 = "] WHERE field1 = condition;" For lng = 200901 To 200906 DoCmd.RunSQL strQ1 & CStr(lng) & strTable & strQ2 Next lng End Sub
Is your code running too slowly?
Does your workbook or database have a bunch of duplicate pieces of data?
Have a look at this article to learn the best ways to set up your projects.
It will save both time and effort in the long run!
Dave
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks