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: - strSQL = "SELECT * FROM [tbl_SponsorList] INNER JOIN [tbl_SponProd] ON [tbl_SponsorList].[Sponsor_ID] = [tbl_SponProd].[Sponsor_ID] ORDER BY [Prod_Date]"
-
DoCmd.RunSQL strSQL
Hope you have a minute to assist.
Thanks!
J.
7 1780
I split the thread seeing as how this is a new question.
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.
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?
You could try using an ADO recordset, using your SQL statement as the data source:- - Dim RS as ADO.Recordset
-
Set Rs = New ADODB.Recordset
-
strSql = "Select * From........."
-
Rs.Open strSql, ConnectionString
You can then MOVE thru' the recordset, get a record count, etc
HTH
Steve
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"
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
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. Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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:
...
|
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...
|
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...
|
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.
...
|
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
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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...
|
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...
|
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...
| |