From: Mike on 28 Apr 2010 06:21 On a form I have a ComboBox (Combo8). Is there a way to base a query on the value of what is selected in the ComboBox? Here is the SQL statement I've created, that is not working: SELECT [Combo8.value].DRAWING, [Combo8.value].[EQUIPMENT/CIRCUITS], [Combo8.value].[CABLE TYPE], [Combo8.value].[FND/SEQ], [Combo8.value].COMPT, [Combo8.value].LEX, [Combo8.value].ZONE, [Combo8.value].BILL, [23Tag and TM Data].[To Eq], [23Tag and TM Data].[To Desc], [23Tag and TM Data].[From Eq], [23Tag and TM Data].[From Desc] FROM Combo8 LEFT JOIN [23Tag and TM Data] ON Combo8.value.[EQUIPMENT/CIRCUITS]=[23Tag and TM Data].[Circuit Number]; I am trying to join the "23Tag and TM Data" table to the table represented in the ComboBox (Combo8) and then run the query.
From: Tom van Stiphout on 28 Apr 2010 10:40 On Wed, 28 Apr 2010 03:21:01 -0700, Mike <Mike(a)discussions.microsoft.com> wrote: I understand you have a bunch of tables with same colums, and a dropdown with those table names. Now you want to query the selected table. First off, you probably have a REALLY BAD database design that will come back to bite you many more times. Create a relational database so the problem will go away altogether. Combo8 is also a non-descriptive name. How about cboTables? Chances are I did not convince you and you will press on. To do what you want, you would have to concatenate a string with the desired sql statement. Something like: dim sql as string sql = SELECT " & Combo8.Value & ".DRAWING," & Combo8.value & ".[EQUIPMENT/CIRCUITS]," & etc. -Tom. Microsoft Access MVP >On a form I have a ComboBox (Combo8). Is there a way to base a query on the >value of what is selected in the ComboBox? > >Here is the SQL statement I've created, that is not working: > >SELECT [Combo8.value].DRAWING, [Combo8.value].[EQUIPMENT/CIRCUITS], >[Combo8.value].[CABLE TYPE], [Combo8.value].[FND/SEQ], [Combo8.value].COMPT, >[Combo8.value].LEX, [Combo8.value].ZONE, [Combo8.value].BILL, [23Tag and TM >Data].[To Eq], [23Tag and TM Data].[To Desc], [23Tag and TM Data].[From Eq], >[23Tag and TM Data].[From Desc] >FROM Combo8 LEFT JOIN [23Tag and TM Data] ON >Combo8.value.[EQUIPMENT/CIRCUITS]=[23Tag and TM Data].[Circuit Number]; > >I am trying to join the "23Tag and TM Data" table to the table represented >in the ComboBox (Combo8) and then run the query.
|
Pages: 1 Prev: 回覆: Select Max, return unwanted rows. Next: Report + chart |