Help with Code behind my report.

  • Thread starter graeme34 via AccessMonster.com
  • Start date
G

graeme34 via AccessMonster.com

Hi

Could anybody help me out with the code:
I have a despatch note report, with a subreport for the detail.
Within the detail are the bound controls, product code, description and
ordered.
I have added an unbound control named outstanding, as an order will not
always be completely sent, there will be times when only part of the order
(line) is sent. So the unbound control is to equal quantity ordered if it is
a first delivery or be equal to quantity ordered - (sumofquantity sent)
(where this value is retrieved from a stored query.
I have tried the following code in the activate event of the subreport, but
it doesnt seem to be working at all:

Private Sub Report_Activate()

Dim rsSum As DAO.Recordset

Set rsSum = CurrentDb.OpenRecordset("qrySumQuantitySent", dbOpenDynaset)

rsSum.FindFirst "[SalesOrderNumber] = " _
& Forms!frmChooseOrderNumber!txtOrderNumberChoice


If rsSum.NoMatch = True Then
Reports!subrepDespatchLine1!txtOutstanding = _
Reports!subrepDespatchLine1!QuantityOrdered
Else
Reports!subrepDespatchLine1!txtOutstanding = _
Reports!subrepDespatchLine1!QuantityOrdered - _
rsSum![SumOfQuantity Sent]
End If
End Sub

Also I assume there need to be a loop in there somewhere for each detail line.

One last question, the stored query originally had the criteria
WHERE(tbldespatch.salesordernumber = Forms!frmChooseOrderNumber!
txtOrderNumberChoice)
although when I tried to use the OpenRecordset command on the query I didnt
like it for some reason but work fine with the WHERE criteria. hence having
to use the FINDFIRST method on the recordset, which I assume lessens the
performance??
I may be wrong, still a newbie to Access.
Thanks in advance.
Graeme
 

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

Top