Dim mlOrderID As Variant
Dim rs As New ADODB.Recordset
Dim varBkmk As Variant
rs.ActiveConnection = CurrentProject.Connection
With rs
.Open "tblOrders", , adOpenStatic, adLockOptimistic, adCmdTable
.AddNew
!CustomerID = Me.CustomerID
!Item = Me.Item
!Qty = Me.Qty
!UnitPrice = Me.UnitPrice
.Update
mlOrderID = !OrderID ' Get OrderID from new record
MsgBox "New OrderID is " & mlOrderID, vbOKOnly '为何会出差错
.Close
End With
Set rs = Nothing