T
Tara
I have a parent form (frmCustomers) with Customer Contact information and a
subform to track receipts for those customers. On the parent form, I have a
combo box which has the On Not In List event set to open a form
(frmAddCustomer) where users can add a new customer. This all works fine.
But what isn't working fine is the After Update event. What I currently have
is the After Update event in the combo box on the main form set to refresh
the data on the parent form. But it's not working. Here is the code I have
for both the Not In List event and the After Update event:
Private Sub CboCustomer_NotInList(NewData As String, Response As Integer)
Dim strMsg As String
strMsg = "'" & NewData & "' is not currently in the list of businesses "
& vbCrLf & vbCrLf
strMsg = strMsg & "Do you want to add this business to the current list?"
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new business?") = vbYes Then
Response = acDataErrContinue
DoCmd.OpenForm "frmAddCustomer", , , , , acDialog
Response = acDataErrAdded
End If
End Sub
Private Sub CboCustomer_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[CustID] = " & Str(Me![CboCustomer])
Me.Bookmark = rs.Bookmark
Me.sbfReceipts.Requery
Me.sbfReceipts.SetFocus
DoCmd.GoToRecord , , acNewRec
End Sub
What I'm really wondering though is if I shouldn't do something when
frmAddCustomers closes to refresh the parent form data, rather than having
something in the AfterUpdate event in the combo.
Any suggestions or advice is appreciated!
subform to track receipts for those customers. On the parent form, I have a
combo box which has the On Not In List event set to open a form
(frmAddCustomer) where users can add a new customer. This all works fine.
But what isn't working fine is the After Update event. What I currently have
is the After Update event in the combo box on the main form set to refresh
the data on the parent form. But it's not working. Here is the code I have
for both the Not In List event and the After Update event:
Private Sub CboCustomer_NotInList(NewData As String, Response As Integer)
Dim strMsg As String
strMsg = "'" & NewData & "' is not currently in the list of businesses "
& vbCrLf & vbCrLf
strMsg = strMsg & "Do you want to add this business to the current list?"
If MsgBox(strMsg, vbQuestion + vbYesNo, "Add new business?") = vbYes Then
Response = acDataErrContinue
DoCmd.OpenForm "frmAddCustomer", , , , , acDialog
Response = acDataErrAdded
End If
End Sub
Private Sub CboCustomer_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[CustID] = " & Str(Me![CboCustomer])
Me.Bookmark = rs.Bookmark
Me.sbfReceipts.Requery
Me.sbfReceipts.SetFocus
DoCmd.GoToRecord , , acNewRec
End Sub
What I'm really wondering though is if I shouldn't do something when
frmAddCustomers closes to refresh the parent form data, rather than having
something in the AfterUpdate event in the combo.
Any suggestions or advice is appreciated!