I can't figure out how to modify this code? (1 Viewer)

LKE

New member
Local time
Today, 16:34
Joined
May 3, 2002
Messages
6
I have a feeling this is a relatively easy question, but my brain appears to be maxed-out. Any help would be greatly appreciated!

I have several forms linked to each other by a "RPS ID" number. At the bottom of each form I have placed a button that a.) opens the next form and b.) fills in the ID number on the newly opened form. However, the code does not include closing the previous form. For example, I have attached the code of form IV that a.) carries over the ID number from form III and b.) opens form V and automatically places the ID number on that form (well, that's the load event on Form V). However, how can I get Form IV to close???? Thanks very much for your help!

Code:

Option Compare Database
Private Sub Form_Load()
Me!txtRPSID = Me.OpenArgs

End Sub

Private Sub CommandtoSectionV_Click()
On Error GoTo Err_CommandtoSectionV_Click

Screen.PreviousControl.SetFocus
DoCmd.FindNext
Exit_CommandtoSectionV_Click:
Exit Sub
Err_CommandtoSectionV_Click:
MsgBox Err.Description
Resume Exit_CommandtoSectionV_Click

End Sub
Private Sub toform5_Click()
On Error GoTo Err_toform5_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Section V: Location"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_toform5_Click:
Exit Sub
Err_toform5_Click:
MsgBox Err.Description
Resume Exit_toform5_Click

End Sub
Private Sub OpenSectionV_Click()
On Error GoTo Err_OpenSectionV_Click
DoCmd.OpenForm "Section V: Location", , , , acFormAdd, , Me![RPS ID].Value

Exit_OpenSectionV_Click:
Exit Sub
Err_OpenSectionV_Click:
MsgBox Err.Description
Resume Exit_OpenSectionV_Click

End Sub
 

LKE

New member
Local time
Today, 16:34
Joined
May 3, 2002
Messages
6
It seemed to work to put the close form code in the load event of the second form (after the ID number was already filled in based on the first form). However, any thoughts on how to SAVE and close the previous form? I have certain fields that are required on the first form and when it is closed (by the second form), it does not save the record when the required fields are left blank (it also doesn't tell you that a required field was left blank). Any thoughts?
 

Users who are viewing this thread

Top Bottom