General discussion
July 3, 2002 at 02:36 AM
carljohnman

Help with form code

by carljohnman . Updated 24 years, 1 month ago

I created a command button that opens a second form in order passing the primary key and closing only if you save the record. I figured if a user makes a mistake entering data on form 1 they could probably use a command button on form 2 to take themback to the same record on form 1 and open it passing the primary just like I done on form 1. I reversed the form names because the logic seems the same but form 1 always defaults to the first primary key when the back command is clicked on form 2. The code for Form1 and Form2 is below, Can someone please help me I am losing my mind? Everything works but the primary key passing from form 2 to form 1. Thanks very much in advance to anyone that can help and I need to mention I have very little experience with code.

Form 1 Command Next Code:

Private Sub Command28_Click()
On Error GoTo Err_Command28_Click

Dim stDocName As String
Dim stLinkCriteria As String

If Me.Dirty Then
MsgBox “Please click on the Save Button”, vbOKOnly
Else

stDocName = “Probatedb Test Form1”
DoCmd.OpenForm stDocName, acNormal, , , , , Me!
[Probatedb TestID]
DoCmd.Close acForm, Me.Name
End If

Exit_Command28_Click:
Exit Sub

Err_Command28_Click:
MsgBox Err.Description
Resume Exit_Command28_Click

End Sub

Form 2 Command Back Code:

Private Sub Command34_Click()
On Error GoTo Err_Command34_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = “Probatedb Test Information Form”
DoCmd.OpenForm stDocName, acNormal, , , , , Me!
[Probatedb TestID]
DoCmd.Close acForm, Me.Name
Exit_Command34_Click:
Exit Sub

Err_Command34_Click:
MsgBox Err.Description
Resume Exit_Command34_Click

End Sub

This discussion is locked

All Comments