bossmack916
New member
- Local time
- Yesterday, 18:34
- Joined
- Mar 28, 2012
- Messages
- 6
I have a "Main Form" with a "Add New Order" button. When I click on "Add New Order" , the "Orders" form opens and allows you to add a new order. On this form is an "Order ID" field that keep record of the order number. However, everytime I open a new "Orders" form, the order ID skips a number and a blank row is populated in the "Orders" Table, which the form is linked to. Why does this occur? How can I prevent this from happening? Below is the code I have for the "Add New Order" button on the "Main" form.
Private Sub cmdAddOrder_Click()
On Error GoTo Err_cmdAddOrders_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim intOrderID As Integer
intOrderID = lngGetNewOrderID
stLinkCriteria = "Orderid = " & lngGetNewOrderID
stDocName = "FrmOrders"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdAddOrders_Click:
Exit Sub
Err_cmdAddOrders_Click:
MsgBox Err.Description
Resume Exit_cmdAddOrders_Click
End Sub
Private Sub cmdAddOrder_Click()
On Error GoTo Err_cmdAddOrders_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim intOrderID As Integer
intOrderID = lngGetNewOrderID
stLinkCriteria = "Orderid = " & lngGetNewOrderID
stDocName = "FrmOrders"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdAddOrders_Click:
Exit Sub
Err_cmdAddOrders_Click:
MsgBox Err.Description
Resume Exit_cmdAddOrders_Click
End Sub