Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Join Statements

Status
Not open for further replies.

svm

Programmer
Apr 26, 2001
44
US
I am new to VB and I have a hard time coming up with the correct syntax coding for this.

strSQL = Select * From tblProjectInfo Inner Join_ tblBidInfo on tblProjectInfo.F_Number =_
tblBidInfo.F_Number _
Where tblProjectInfo.Probability% > 74 _
And tblProjectInfo.Job_Status = "Pending" And tblBidInfo.Base_Alt = "Base""


What's the correct syntax. Appreciate to whatever help you can give me on this. Thanks.
 
You enclose string values in single tick (') instead of the quotation mark. David Paulson

 
I tried doing that but still i'm getting a compile error.
 
you also need to identify what fields you want to select from tblBidInfo.
such as:
Select tblProjectInfo.*, tblBidInfo.F_Number, tblBidInfo.F_Size, tblBidInfo.F_Amnt Inner....

(Check my syntax though..) Tim

Remember the KISS principle:
Keep It Simple, Stupid!
 
svm -

The people at work hate me for this, but you might want to re-format your code to make it more readable:
[tt]
sSQL = ""
sSQL = sSQL & " SELECT tblProjectInfo.Column1,"
sSQL = sSQL & " tblProjectInfo.Column2"
sSQL = sSQL & " FROM tblProjectInfo"
sSQL = sSQL & " INNER JOIN tblBidInfo ON"
sSQL = sSQL & " tblProjectInfo.F_Number = tblBidInfo.F_Number"
sSQL = sSQL & " WHERE tblProjectInfo.Probability>74"
sSQL = sSQL & " AND tblProjectInfo.Job_Status='Pending'"
sSQL = sSQL & " AND tblBidInfo.Base_Alt='Base'"
[/tt]
I've changed the select clause to bring back only the columns you need (database guys hate to see "SELECT *"). I've also changed the column name for Probability to remove the percent-sign, as this symbol is used as a wildcard in SQL for use with the LIKE operator. I've also changed the quotes around your string literals to the single-quotes.

Style-wise, I like to keep the single space at the front of each line (most people put it at the end) because then I can immediately see where one was left off (instead of zig-zagging down the ends of the lines). I also like to capitalize SQL keywords to make them stand out.

Chip H.


 
Arrggg!
Stupid Tek-Tips word-wrap screwed it up. But you get the idea. Cut and paste it into VB and you'll see.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top