Adding items from another query in a form

  • Thread starter Thread starter Jasper Recto
  • Start date Start date
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top