On my form (fm_Inventory) there is a sub form (frm_inventory_sub)
On that sub form there is a field labeled DCN.
On the After Update Event I have the following code:
Dim stDOCName As String
Dim stLinkCriteria As String
Dim Sid As String
If IsNull(Me.DCN) Then Exit Sub
Sid = Me.DCN.Value
stDOCName = "frm_Inventory"
stLinkCriteria = "DCN=" & "'" & Sid & "'"
If DCount("DCN", "qry_Inventory_Dups", stLinkCriteria) > 0 Then
'Undo duplicate entry
'Message box warning of duplication
MsgBox "Warning DCN: " _
& Sid & " has already been entered." _
& vbCr & vbCr & "You will now been taken to the record.", vbInformation _
, "Duplicate Information"
'Go to record of original Employee
Cancel = True 'add this line
DoCmd.Close acForm, "frm_Inventory"
DoCmd.OpenForm stDOCName, , , stLinkCriteria
Everything works great up to the end. It finds the duplicates but when ti goes to open frm_inventory it can't.
I know the link criteria needs to change to open up the hardware with the record with the DCN in it.
I have never done this via a sub form. I know I would need to add a new variable for the Hardware_ID Field
But how do I tell the code to open the correct record?