I have a pop-up form which shows records from a secondary table associated with the record selected on a main form. The pop-up opens with the following code on a command button:
[tt]
Private Sub cmdFailCodes_Click()
On Error GoTo Err_cmdFailCodes_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Failure Codes"
stLinkCriteria = "[QAinProcInspTimesID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdFailCodes_Click:
Exit Sub
Err_cmdFailCodes_Click:
MsgBox Err.Description
Resume Exit_cmdFailCodes_Click
End Sub
[/tt]
The form shows up in continuous forms view, and users can add new records.
The problem is how to have the QAinProcInspTimesID for new records fill in with the default value of Me![ID] that was used to open the form - now that we're on a different form and Me![ID] has been left behind. I would have it reference an existing record pulled by the pop-up, but usually there won't be any records pulled when the form first opens, because they won't yet exist.
Cheryl dc Kern
[tt]
Private Sub cmdFailCodes_Click()
On Error GoTo Err_cmdFailCodes_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Failure Codes"
stLinkCriteria = "[QAinProcInspTimesID]=" & Me![ID]
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdFailCodes_Click:
Exit Sub
Err_cmdFailCodes_Click:
MsgBox Err.Description
Resume Exit_cmdFailCodes_Click
End Sub
[/tt]
The form shows up in continuous forms view, and users can add new records.
The problem is how to have the QAinProcInspTimesID for new records fill in with the default value of Me![ID] that was used to open the form - now that we're on a different form and Me![ID] has been left behind. I would have it reference an existing record pulled by the pop-up, but usually there won't be any records pulled when the form first opens, because they won't yet exist.
Cheryl dc Kern