I have two forms. They are both linked to different tables. In addition form 1 corresponds to form 2 through an ID value (text box). If the user inputs a ID value that already exists in form 1, I want the corresponding form 2 to open. Basically I want to open a specific form. I have written the code below. When this code is implemented, it opens all 500 forms no matter what I input in the ID value. I have found many similar posts but I am still not able to debug my problem. I am pressed on time and would appreciate any suggestions. Thanks.
Private Sub dnum_Exit(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
Num = DLookup("[dnum]", "All Data Table", "[dnum]=[All Data Table].[Docket No]")
Suf = DLookup("[dsuf]", "All Data Table", "[dsuf]=[All Data Table].[Docket No Suffix]")
Pre = DLookup("[dpre]", "All Data Table", "[dpre]=[All Data Table].[Docket No Prefix]")
If Not IsNull(Suf) Then
Beep
MsgBox "The Docket Suf Already exists", vbOKOnly, "Duplicate Value"
stDocName = "Dockets Data Input Form"
stLinkCriteria = "[Docket No Suffix]=" & "'" & Me![dsuf] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If
End Sub