M
Matt via AccessMonster.com
I have a form to capture our shop orders. However at times we people try to
enter a new order in the system that has already been entered. The database
is set to only allow duplicate order numbers, but I have other feilds that
are required and the order entry person doesn't know the order was already
entered until after they have completed the entry of all feilds and go to
save the record.
What I have done is created a AfterUpdate to the OrderNum item, but becuase
my form is open in "acFormAdd" the code fails to open the exsisting record.
Can anyone help?
ThanksPrivate Sub cmdAddNew_Click()
Dim stDocName As String
stDocName = "frmOrderEntryOnly"
DoCmd.OpenForm stDocName, , , , acFormAdd
End SubPrivate Sub OrderNum_AfterUpdate()
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
stLinkCriteria = "[OrderNum]=" & "'" & SID & "'"
'Check table for existing order number.
If DCount("OrderNum", "tblShopOrders", stLinkCriteria) >= 1 Then
'Go to record with matching order number
DoCmd.ShowAllRecords
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub
enter a new order in the system that has already been entered. The database
is set to only allow duplicate order numbers, but I have other feilds that
are required and the order entry person doesn't know the order was already
entered until after they have completed the entry of all feilds and go to
save the record.
What I have done is created a AfterUpdate to the OrderNum item, but becuase
my form is open in "acFormAdd" the code fails to open the exsisting record.
Can anyone help?
ThanksPrivate Sub cmdAddNew_Click()
Dim stDocName As String
stDocName = "frmOrderEntryOnly"
DoCmd.OpenForm stDocName, , , , acFormAdd
End SubPrivate Sub OrderNum_AfterUpdate()
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
stLinkCriteria = "[OrderNum]=" & "'" & SID & "'"
'Check table for existing order number.
If DCount("OrderNum", "tblShopOrders", stLinkCriteria) >= 1 Then
'Go to record with matching order number
DoCmd.ShowAllRecords
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub