Adding items from another query in a form

J

Jasper Recto

I have a continuous form (frmProduction) that was created from the query
qryLabor.

I have another query called qryLaborSum that uses the qryLaborCosts to sum
up a few fields so I can get the total cost.

I want to add the qrylaborSum information on the footer of the frmProduction
form without using a subreport.

How would I do that?

Thanks,
Jasper
 
G

Graham R Seach

I assume you want only a single value; the sum? If so, then I'd say do it in
code in the form's Current event:

Private Sub Form_Current()
Dim db As Database
Dim rs As DAO.Recordset
Dim strSQL As String

strSQL "SELECT * FROM qryLabourSum WHERE somefield = " & Me!txtsomefield

Set db = CurrentDb
Set rs=db.OpenRecordset(strSQL,dbOpenSnapshot)
Me!txtSum = Nz(rs!SumOfLabourCosts, 0)

rs.Close
Set rs = Nothing
Set db = Nothing
End Sub

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
Top