The following code creates a new order, and a new order detail at the same time, which is what I was trying to do. The only problem is I want to set the value of OrderID in the newly created Order detail record, to the OrderID of the new order that was just created. Where I have !OrderID = Me.OrderID, thats wrong. It just fills in the number from the record you're on. Is there any way to tell it to put the number of the most recent Order, which in this case would be the one I just created? Or is there a better way to do this????
Private Sub Command50_Click()
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Orders"
With rs
.AddNew
.Update
End With
Set db = CurrentDb
Set rs = db.OpenRecordset("Order Details"
With rs
.AddNew
!OrderID = Me.OrderID
.Update
End With
db.Close
End Sub
Private Sub Command50_Click()
Dim db As Database
Dim rs As Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("Orders"
With rs
.AddNew
.Update
End With
Set db = CurrentDb
Set rs = db.OpenRecordset("Order Details"
With rs
.AddNew
!OrderID = Me.OrderID
.Update
End With
db.Close
End Sub