PC Review


Reply
Thread Tools Rate Thread

ComboBox related query

 
 
Mike
Guest
Posts: n/a
 
      28th Apr 2010
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.
 
Reply With Quote
 
 
 
 
Tom van Stiphout
Guest
Posts: n/a
 
      28th Apr 2010
On Wed, 28 Apr 2010 03:21:01 -0700, Mike
<(E-Mail Removed)> 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.

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Advice on populating combobox - Threading/Background Worker/Application.DoEvents related Rob W Microsoft VB .NET 13 24th Aug 2009 03:40 PM
3 questions related to ImageList, ListView and ComboBox Steve K. Microsoft C# .NET 4 8th Apr 2008 04:48 AM
2 questions! Related to combobox and time function. HELP!! =?Utf-8?B?QnJ1bm8=?= Microsoft Excel Misc 11 28th Sep 2007 02:33 PM
query related to itself Chris Nebinger Microsoft Access Queries 0 22nd Sep 2004 10:53 PM
Binding a combobox to a related DataTable Lorenz Kahl Microsoft ADO .NET 0 6th Sep 2004 04:24 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:48 AM.