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

Excel VBA SQL problem. 1

Status
Not open for further replies.

kodr

Programmer
Dec 4, 2003
368
Okay, I'm stumped. It's probably something simple.

Code:
sSQL = "SELECT MAX[INTERVAL_ARRIVALS] AS lMaxIA, [Time] as sTime FROM tblCONG WHERE iIndex = 40 GROUP BY lMaxIA, sTime"
rs2.open sSQL, Conn, adOpenStatic, adLockOptimistic
lMaxIA = rs2.Fields(0).value
sPeriod = rs2.Fields(1).value

The above code errors out at the rs2.open line with "No value given for one or more required parameters."

Anyone have any ideas?

Thanks.
 


Hi,

Don't use the aggregated field in your Group By...
Code:
sSQL = "SELECT MAX[INTERVAL_ARRIVALS] AS lMaxIA, [Time] as sTime "
sSQL = sSQL & "FROM tblCONG "
sSQL = sSQL & "WHERE iIndex = 40 "
sSQL = sSQL & "GROUP BY sTime"

rs2.open sSQL, Conn, adOpenStatic, adLockOptimistic
lMaxIA = rs2.Fields(0).value
sPeriod = rs2.Fields(1).value


Skip,

[glasses] [red][/red]
[tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top