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
Where GetOrderNumber is a public function which prompts the user to enter the
order number in an input box.
The subroutine then 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
it to
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
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
Where GetOrderNumber is a public function which prompts the user to enter the
order number in an input box.
The subroutine then 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
it to
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