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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select statement, multiple tables

Status
Not open for further replies.

jabenj

Technical User
Joined
Dec 18, 2008
Messages
20
Location
US
Once again I'm stuck. Shocker. I'm trying to take data from multiple tables and Sum them. I think what I have should work, but I keep getting a runtime error 2465 saying the field "'" can't be found. Do I need to do a join statement? Help is appreciated. Thanks

Dim con As Object
Dim rs As Object
Dim stSql As String
Dim currentweight As Long


Set con = Application.CurrentProject.Connection
stSql = "SELECT Sum([TransferredWeight]) - Sum([[Weight]) FROM tblLatexBatchQC, [Blendsheet Output] AS currentweight"
stSql = stSql & " WHERE tblLatexBatchQC.[TankNum] = '" & [Blendsheet Output].TankN & Me.cmbTankNum & "';"
Set rs = CreateObject("ADODB.Recordset")
rs.Open stSql, con, 1

TxtCurrentWeight.SetFocus
currentweight = rs![currentweight]
TxtCurrentWeight.Text = currentweight
 
stSql = "SELECT Sum([TransferredWeight]) - Sum([[Weight]) FROM tblLatexBatchQC, [Blendsheet Output] AS currentweight"
stSql = stSql & " WHERE tblLatexBatchQC.[TankNum] = [Blendsheet Output].TankN" & Me.cmbTankNum & ";"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanks for the help. I tried that and now I get another message saying no value given for one or more parameters. Haven't had a chance to play with it yet to figure out why. I'm guessing something missing in my table or a problem with one of my variables.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top