473,402 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Problem with Join

Good Luck.
Hi again, Rabbit.

I started the work on the next piece of this puzzle I'm developing.

I laid down most of the code, have one issue with a JOIN statement.

Can you take a look at this, tell me if you see where my problem is? It is definitley in this line of code:

Expand|Select|Wrap|Line Numbers
  1. strSQL = "SELECT * FROM [tbl_SponsorList] INNER JOIN [tbl_SponProd] ON [tbl_SponsorList].[Sponsor_ID] = [tbl_SponProd].[Sponsor_ID] ORDER BY [Prod_Date]"
  2. DoCmd.RunSQL strSQL
Hope you have a minute to assist.

Thanks!

J.
May 2 '07 #1
7 1780
Rabbit
12,516 Expert Mod 8TB
I split the thread seeing as how this is a new question.
May 2 '07 #2
Rabbit
12,516 Expert Mod 8TB
Again, this is the same problem as the previous thread, you can't use a SELECT SQL statement with DoCmd.RunSQL. It just doesn't work no matter how you rephrase it.

To see the results of the select statement you have to do it through a query. This query can then be represented by a form if you so wish.
May 2 '07 #3
Again, this is the same problem as the previous thread, you can't use a SELECT SQL statement with DoCmd.RunSQL. It just doesn't work no matter how you rephrase it.

To see the results of the select statement you have to do it through a query. This query can then be represented by a form if you so wish.
Sorry, this is not clear to me. Can you give me an example that I can work from?
May 3 '07 #4
cyberdwarf
218 Expert 100+
You could try using an ADO recordset, using your SQL statement as the data source:-

Expand|Select|Wrap|Line Numbers
  1. Dim RS as ADO.Recordset
  2. Set Rs = New ADODB.Recordset
  3. strSql = "Select * From........."
  4. Rs.Open strSql, ConnectionString
You can then MOVE thru' the recordset, get a record count, etc

HTH

Steve
May 3 '07 #5
Rabbit
12,516 Expert Mod 8TB
Sorry, this is not clear to me. Can you give me an example that I can work from?
I can't give you an example because I have no idea what you want to use the SELECT statement for. I can only assume you want the user to view the results of the query. Is that the case?

If so you just make the query and open it in the code with
DoCmd.OpenQuery "NameOfQuery"
May 3 '07 #6
Rabbit,

Basically, I just need to JOIN two unrelated tables (at a related field) so I can generate a query based on the results.

Forgetting the query piece for now - how can I use an INNER JOIN statement in VBA to join two tables?

If you look at my 3 lines of code, you can see how I was attempting to accomplish this.

Thanks again,

J
May 24 '07 #7
Rabbit
12,516 Expert Mod 8TB
Rabbit,

Basically, I just need to JOIN two unrelated tables (at a related field) so I can generate a query based on the results.

Forgetting the query piece for now - how can I use an INNER JOIN statement in VBA to join two tables?

If you look at my 3 lines of code, you can see how I was attempting to accomplish this.

Thanks again,

J
You say you want to join two tables and generate a query based on the results.

Again, it's the same thing I've been trying to get across the whole time, a non-action SQL statement can not be run using RunSQL. The only SQL statements what work with RunSQL are Update, Insert, Create, Drop, etc. Basically SQL statements that actually affect the tables.

A select statement doesn't do anything to the tables, neither does a crosstab query. A join doesn't affect the tables either. Basically, using RunSQL on a non-action SQL statement accomplishes nothing. If you want to view the results of said SQL statement, create a query and then open it using code like I laid out earlier. I'm not even sure what you want. I assume you want to see the results of the SQL Statement.

Bottom Line: You can't use DoCmd.RunSQL to do what you want.
May 24 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Ling Lee | last post by:
Hello. I'm trying to write a small program that lets you put in a number as an integer and then it tells you the textuel representation of the number. Like if your input is 42, it will say...
2
by: Bruce Duncan | last post by:
I'm a bit new to MySQL (know MS SQL well...and that may be the problem...getting the syntax confused) and I'm having a join problem...can anyone offer some help? Here's my problem: I have table1...
1
by: Keith | last post by:
I have created a view to test some of the data in my database. I am relatively new to SQL so may have caused this problem by doing something wrong. I have a table called SYS_Individual which...
14
by: signaturefactory | last post by:
I am trying the following query in and oleDbCommand: SELECT PartLocations.LocationName, Sum(PartsJournal.Quantity) AS SumOfQuantity, PartsJournal.PartsLotNumber FROM PartLocations INNER JOIN...
8
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
1
by: Andrew McNab | last post by:
Hi folks, I have a problem with an MS Access SQL query which is being used in an Access Report, and am wondering if anyone can help. Basically, my query (shown below) gets some records from a...
27
by: John Salerno | last post by:
Ok, here's a problem I've sort of assigned to myself for fun, but it's turning out to be quite a pain to wrap my mind around. It's from a puzzle game. It will help if you look at this image: ...
1
by: imranpariyani | last post by:
Hi i have a severe performance problem with one of my views which has 6 to 8 joins .. any help will be appreciated.. the view is: CREATE OR REPLACE VIEW thsn.trade_view AS SELECT...
9
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just...
3
by: Anila | last post by:
Hi Friends, My problem with Inner join is ... first i joined two tables and i got the result. after that iam trying to join one more table its giving syn tax error in JOIN condition. ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.