D
Dan
I have some unbound fields on an Orders form that gather information,
validate it, and then define a new record when the user moves to the
OrderDetails subform. The code I have in the OrderDetails subform's Enter
method is as follows:
<CODE>
Dim DBS As DAO.Database
Dim rstNewOrder As DAO.Recordset
Dim NewOrderID As Integer
Set DBS = CurrentDb
Set rstNewOrder = DBS.OpenRecordset("tblOrders", dbOpenDynaset)
With rstNewOrder
.AddNew
!CustID = strCustID
!OrderDate = CDate(strOrderDate)
!ShipDate = CDate(strShipDate)
.Update
.Bookmark = .LastModified
NewOrderID = !OrderID
.Close
End With
Set rstNewOrder = Nothing
Set DBS = Nothing
</CODE>
I need to set the OrderID as a field in the OrderDetails table.
1. Is this the way to retrieve the new OrderID from the newly-created Orders
table?
2. How do I set the OrderID in the OrderDetails subform to this value?
Thanks!
validate it, and then define a new record when the user moves to the
OrderDetails subform. The code I have in the OrderDetails subform's Enter
method is as follows:
<CODE>
Dim DBS As DAO.Database
Dim rstNewOrder As DAO.Recordset
Dim NewOrderID As Integer
Set DBS = CurrentDb
Set rstNewOrder = DBS.OpenRecordset("tblOrders", dbOpenDynaset)
With rstNewOrder
.AddNew
!CustID = strCustID
!OrderDate = CDate(strOrderDate)
!ShipDate = CDate(strShipDate)
.Update
.Bookmark = .LastModified
NewOrderID = !OrderID
.Close
End With
Set rstNewOrder = Nothing
Set DBS = Nothing
</CODE>
I need to set the OrderID as a field in the OrderDetails table.
1. Is this the way to retrieve the new OrderID from the newly-created Orders
table?
2. How do I set the OrderID in the OrderDetails subform to this value?
Thanks!