having trouble with Opening a specific form

SD23

Registered User.
Local time
Yesterday, 16:13
Joined
Jun 13, 2006
Messages
60
I have a form with a certain ID number that the User enters. The ID number is 3 fields (2 text and 1 numeric). The two texts are pull down boxes. If the user enters an ID number that already exists, I have a message that says "This ID number Already exists." I have the code that searches for the duplicate values of the ID number. It works fine.

Each form is linked to another form. After you are finished with the first form, you click submit and that ID number is linked with a second form. If the ID already exists, I wanted to open the second form that is linked with the inputted ID.

Currently, my code opens the second form, but it always opens the form with the ID = 1. It does not open the second form with the corresponding ID. Any suggestions on how I can fix this problem. I have searched and found many posts of similar problems but I am still having difficulties. Thanks for the help.

Private Sub dsuf_Exit(Cancel As Integer)

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]")
Dim strSQL As String
Dim stDocName As String
Dim stLinkCrieria As String

If Not IsNull(Num) And Not IsNull(Suf) And Not IsNull(Pre) Then
Beep
MsgBox "The Docket Number Already exists", vbOKOnly, "Duplicate Value"

stDocName = "Dockets Data Input Form"
stLinkCriteria = "[dnum] = " & Num & " And [dsuf] = '" & Suf & "’ And [dpre] = '" & Pre & "’"
DoCmd.OpenForm stDocName, , , , , , stLinkCriteria

End If

End Sub
 

Users who are viewing this thread

Back
Top Bottom