Hi Everyone!
I have a question about using a subform on multiple subforms.
I have a main form that contains a command button that calls a form that contains a "pick" list of entries. When the user double clicks on one of the entries, the entry is entered into a table. The main form then has a subform that displays all entries that the user has selected. I got this to work perfectly... the requery statement at the end ensures that the user can see the entry from the main form immediately.
I would like to use the same form that contains the "pick" list entries and the subform that displays the entries on different forms. When I tested it out it errors out on the requery statement - which is what I expected since the form name is different.
How can I reuse the form without having to copy the form multiple times just to change one line (requery statement)?
Thanks!
code from the "pick" list of entries that user can select to add to a table...
Private Sub ListNMR_DblClick(Cancel As Integer)
Dim strSQL As String
Dim NMR As String
Dim Item As String
Dim Description As String
Dim ChgDT As Date
Dim key As Integer
NMR = Me.ListNMR.Column(0)
Item = Me.ListNMR.Column(1)
Description = Me.ListNMR.Column(2)
strSQL = "INSERT INTO tblNMR_HISTORY (PartStatusId, NCRNumber, ItemName, DiscrepancyDescription, Changed_Time) VALUES (" & NMRKey & ", '" & NMR & "', '" & Item & "','" & Description & "', # " & ChgDT & "#);"
'MsgBox "SQL:" & strSQL
CurrentDb.Execute strSQL, dbFailOnError
DoCmd.Close
Forms!frmTestStatus!sbfNMRHistory.Form.Requery
End Sub
I have a question about using a subform on multiple subforms.
I have a main form that contains a command button that calls a form that contains a "pick" list of entries. When the user double clicks on one of the entries, the entry is entered into a table. The main form then has a subform that displays all entries that the user has selected. I got this to work perfectly... the requery statement at the end ensures that the user can see the entry from the main form immediately.
I would like to use the same form that contains the "pick" list entries and the subform that displays the entries on different forms. When I tested it out it errors out on the requery statement - which is what I expected since the form name is different.
How can I reuse the form without having to copy the form multiple times just to change one line (requery statement)?
Thanks!
code from the "pick" list of entries that user can select to add to a table...
Private Sub ListNMR_DblClick(Cancel As Integer)
Dim strSQL As String
Dim NMR As String
Dim Item As String
Dim Description As String
Dim ChgDT As Date
Dim key As Integer
NMR = Me.ListNMR.Column(0)
Item = Me.ListNMR.Column(1)
Description = Me.ListNMR.Column(2)
strSQL = "INSERT INTO tblNMR_HISTORY (PartStatusId, NCRNumber, ItemName, DiscrepancyDescription, Changed_Time) VALUES (" & NMRKey & ", '" & NMR & "', '" & Item & "','" & Description & "', # " & ChgDT & "#);"
'MsgBox "SQL:" & strSQL
CurrentDb.Execute strSQL, dbFailOnError
DoCmd.Close
Forms!frmTestStatus!sbfNMRHistory.Form.Requery
End Sub