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

Changing tables automatically in Access queries

Status
Not open for further replies.

rloibl

Programmer
Aug 20, 2001
14
GB
I need a way to change the source(table) within a Access query automatically. But this should be done by the user so there must be a way that the user can select which table should get selected via a Form.
 
Could you give us a little more information? If you've got a form that will look the same for different tables, it sounds like your data isn't normalized. Basically, there's not many good reasons for having tables laid out the same as each other--they should all be in one table.
techsupportgirl@home.com
Brainbench MVP for Microsoft Word
 
Hello
Thanks for your help Dreamboat. There is a need for me to make several tables because server performance is to slow in my company. So that means I have a few different tables with the same field names and therefore I need a way that all queries and forms will change the table source so that I don?t have to create for every table another query/form.
 
Let's say you've got an option group with three choices.

Command Some Button On_Click()
Dim dbs
Dim qdef
Dim TableName as string
Dim strSQL
Set dbs = currentdb()
Set qdef = dbs.QureyDefs("YourQuery")
Select case optgrp1
Case 0
Table Name = "Table1"
Case 1
Table Name = "Table2"
Case 3
Table Name = "Table2"
strSql = "Select * from " & tableName
qdf.SQL = strSQL
End Sub Tyrone Lumley
augerinn@gte.net
 
Thanks Databaseguy
You have solved one thing of the problem. The other problem is now the tables will change but also the criteria that I put in is lost and that´s a problem. So this means I have in all different tables the same fields with the same criteria so the fields that have been filtered with a criteria should be changed.

Regards
Robert
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top