?
Solved

4 table join in VB6 MS access

Posted on 2009-04-01
6
Medium Priority
?
376 Views
Last Modified: 2012-05-06
I've been doing some looking and have found a number of topics that address my issue of joining 4 tables from an MS access db in VB6 but none work.  I still get a "too few parameters, 1 expected" error.  It's driving me crazy.  I've put the latest code below but it still gives me that error.  I feel I've been in a big circle.

Can anyone point out what I'm doing wrong?

Thanks,
bob...
======
P.S. I didn;t know how to go back and add to my previous question so I added a new one here.
strsql = "SELECT [Qualifications].*, [QualificationCourses].*, [Roster].*, [Arms].* "
        strsql = strsql & " FROM ((( Qualifications "
        strsql = strsql & " INNER JOIN QualificationCourses ON Qualifications.[CourseID] = QualificationCourses.[ID]) "
        strsql = strsql & " INNER JOIN Roster on Qualifications.[AgentID] = Roster.[ID])"
        strsql = strsql & " INNER JOIN Arms on Qualifications.[ArmsID] = Arms.[ID]) "
        strsql = strsql & " WHERE [Qualifications].License = '" & Trim(userAdminMOD.currentUser.license) & "'"

Open in new window

0
Comment
Question by:bob-hytekltd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 41

Expert Comment

by:ralmada
ID: 24046085
try like this
strsql = "SELECT [Qualifications].*, [QualificationCourses].*, [Roster].*, [Arms].* "
strsql = strsql & " FROM Qualifications "
strsql = strsql & " INNER JOIN QualificationCourses ON Qualifications.[CourseID] = QualificationCourses.[ID] "
strsql = strsql & " INNER JOIN Roster on Qualifications.[AgentID] = Roster.[ID]"
strsql = strsql & " INNER JOIN Arms on Qualifications.[ArmsID] = Arms.[ID] "
strsql = strsql & " WHERE [Qualifications].License = '" & Trim(userAdminMOD.currentUser.license) & "'"

Open in new window

0
 
LVL 65

Accepted Solution

by:
rockiroads earned 800 total points
ID: 24046829
Cant see whats wrong with your sql. Maybe fault is elsewhere where you are using this sql. Might be worth posting how you run this sql. Also, did you step thru the code to find the exact line where it is failing?

FYI
Another way, one I prefer over inner joins is to simply list the tables then perform the joins using the where clause
eg

strsql = "SELECT Qualifications.*, QualificationCourses.*, Roster.*, Arms.* "
strsql = strsql & " FROM Qualifications, QualificationCourses, Roster, Arms "
strsql = strsql & " WHERE Qualifications.CourseID = QualificationCourses.ID "
strsql = strsql & " AND Qualifications.AgentID = Roster.ID"
strsql = strsql & " AND Qualifications.ArmsID = Arms.ID "
strsql = strsql & " AND Qualifications.License = '" & Trim(userAdminMOD.currentUser.license) & "'"


select columns
from
where table1.somefield = table2.somefield
and table1.somefield = table3.somefield

etc
0
 
LVL 28

Assisted Solution

by:TextReport
TextReport earned 800 total points
ID: 24047135
The error "too few parameters, 1 expected" implies you have a typo in one of the field names you have specified in the SQL so triple check each field in each table mentiones, specifically whatching out for spaces etc.

If you can take the result of the SQL into Access and paste into a queries SQL view and it will tell your there when you run it which field it doesn't like as it will as you for a value for it.

Cheers, Andrew
0
Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

 
LVL 41

Assisted Solution

by:ralmada
ralmada earned 400 total points
ID: 24050950
yeah, check your column names. there must be some misspelling in there.
0
 

Author Closing Comment

by:bob-hytekltd
ID: 31565976
Thanks to all that replied.  The problem was in the spelling of one of the field names (I've only been writing this code for 18 years) but the suggestion to not use INNER JOINS was brilliant and I learned a new way of creating SQL statements this way.  A LOT simplier!!!  Thanks again everyone.  Experts Exchange is great... and so are all of the experts who participate!!!
Best to All!
bob...
======
0
 

Author Comment

by:bob-hytekltd
ID: 24053879
In case you all didn't catch my humor... I misspelled "simpiler".
Best,
bob...
=======
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question