Extrat a maximum value as an integer

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am in child development, not software so please forgive if this is absurd.

I am trying to extrct the maximum value from a table and then use it for
another operation. Using what I have in my limited toolbox-of-knowledge, I
created a listbox and used the RowSource property to get the value. What I
don't know is how to now extract the value as an integer. Here's what I've
done:
Dim intKid As Integer
Dim intSchedule As Integer

intKid = Me!KidID
Me!lstCurrSch = "SELECT Max(tblSchedules.SchID) FROM tblKids INNER JOIN
tblSchedules ON (tblKids.KidID = tblSchedules.KidID) AND (tblKids.KidID =
tblSchedules.KidID) AND (tblKids.KidID = tblSchedules.KidID)GROUP BY
tblKids.KidID HAVING (((tblKids.KidID) =" & intKid & "));"

intSchedule = Me!lstCurrSch
<<<<

However, intSchedule resolves as a null value. Help?

Thanks.
 
Dim intKid As Integer
Dim intSchedule As Integer
dim rs as new adodb.recordset

intKid = Me!KidID

rs.open "SELECT Max(tblSchedules.SchID) FROM tblKids INNER JOIN
tblSchedules ON (tblKids.KidID = tblSchedules.KidID) AND (tblKids.KidID =
tblSchedules.KidID) AND (tblKids.KidID = tblSchedules.KidID) GROUP BY
tblKids.KidID HAVING tblKids.KidID =" & intKid , CurrentProject.Connection,
adOpenForwardOnly, adLockReadOnly
if not rs.eof then
intSchedule = rs(0)
else
intSchedule =0
end if
rs.close
set rs = nothing

- Raoul
 
Awesome! Thanks for your help.

JaRa said:
Dim intKid As Integer
Dim intSchedule As Integer
dim rs as new adodb.recordset

intKid = Me!KidID

rs.open "SELECT Max(tblSchedules.SchID) FROM tblKids INNER JOIN
tblSchedules ON (tblKids.KidID = tblSchedules.KidID) AND (tblKids.KidID =
tblSchedules.KidID) AND (tblKids.KidID = tblSchedules.KidID) GROUP BY
tblKids.KidID HAVING tblKids.KidID =" & intKid , CurrentProject.Connection,
adOpenForwardOnly, adLockReadOnly
if not rs.eof then
intSchedule = rs(0)
else
intSchedule =0
end if
rs.close
set rs = nothing

- Raoul
 
Back
Top