Help with my despatch note report

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

graeme34 via AccessMonster.com

Hi

I have command button with the following code on:

Private Sub cmdPrintDespatchNote_Click()

Dim lngOrderNum As Long
Dim rsDes As DAO.Recordset


Set rsDes = CurrentDb.OpenRecordset("tblDespatch")

lngOrderNum = GetOrderNumber

If lngOrderNum = 0 Then
MsgBox "No Order Number Chosen", vbOKOnly, "NO CHOICE!"
Exit Sub
Else

With rsDes
.AddNew
!DespatchNumber = Nz(DMax("[DespatchNumber]", _
"tblDespatch"), 0) + 1
!SalesOrderNumber = lngOrderNum
!DateOfDespatch = Now()
.Update
.MoveLast
End With

End If

End Sub

Which creates a new record in the despatch table, now I'm stuck on how to
populate my report (despatch note) with the required data. I have the
following query built, but when I try to open the report I am prompted with a
parameter value to be added for my report, I assume I need to place some
criteria somewhere in the query, but not too sure where. Ideally I would like
be based on the despatch record I have just added.
Here is the query:

SELECT tblAccount.AccountName, tblAccount.[Account Address 1], tblAccount.
[Account Address 2], tblAccount.[Account Address 3], tblAccount.[Account Town
/ City], tblAccount.[Post Code], tblDespatch.DespatchNumber, tblSalesOrder.
SalesOrderNumber, tblSalesOrder.CustomerOrderNumber, tblSalesOrder.
DeliveryMode, tblSalesOrderLine.[Product Code], tblSalesOrderLine.
QuantityOrdered
FROM ((tblAccount INNER JOIN tblSalesOrder ON tblAccount.AccountIndex =
tblSalesOrder.AccountIndex) INNER JOIN tblDespatch ON tblSalesOrder.
SalesOrderNumber = tblDespatch.SalesOrderNumber) INNER JOIN tblSalesOrderLine
ON tblSalesOrder.SalesOrderNumber = tblSalesOrderLine.SalesOrderNumber;

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