wvandenberg
Technical User
Hi all,
I have a form (frmAddNewClient) that contains a combobox (cboClientName) and a subform (sfrAddNewProject). If the desired client is not in the list, the NotInList event fires and the new data is added.
This event works correctly.
I also have code in the AfterUpdate event of cboClientName so that if the desired client is in the list, it will go to the selected record.
The problem I'm having is when the user enters a new ClientName and the NotInList event fires, the form does not go to the newly added data. It just stays on the record that was selected when the user typed the new ClientName.
If I close and reopen the form, I can select the most recently added data and it will go the the record. However, if I don't close and reopen, the rst.FindFirst command produces a NoMatch=True. I've tried requering the form and it just causes the NotInList event to keep firing and I get the NewData added to my table over and over.
Can anyone suggest how I can get the form to goto the NewData added to the combobox?
Thanks,
Wendy
I have a form (frmAddNewClient) that contains a combobox (cboClientName) and a subform (sfrAddNewProject). If the desired client is not in the list, the NotInList event fires and the new data is added.
Code:
Private Sub cboClientName_NotInList(NewData As String, Response As Integer)
If AddToList(Me, "tblClients", "ClientName") Then
Response = acDataErrAdded
Else
Me.cboClientName.Undo
Response = acDataErrContinue
End If
End Sub
This event works correctly.
I also have code in the AfterUpdate event of cboClientName so that if the desired client is in the list, it will go to the selected record.
Code:
Private Sub cboClientName_AfterUpdate()
Dim rst As DAO.Recordset
Set rst = Me.Recordset.Clone
rst.FindFirst "[pkClientID] = " & str(Me.cboClientName)
Me.Bookmark = rst.Bookmark
Set rst = Nothing
If Not IsNull(Me.cboClientName) Then
Me.sfrAddNewProject.Controls("txtProjectNumber").Enabled = True
End If
End Sub
The problem I'm having is when the user enters a new ClientName and the NotInList event fires, the form does not go to the newly added data. It just stays on the record that was selected when the user typed the new ClientName.
If I close and reopen the form, I can select the most recently added data and it will go the the record. However, if I don't close and reopen, the rst.FindFirst command produces a NoMatch=True. I've tried requering the form and it just causes the NotInList event to keep firing and I get the NewData added to my table over and over.
Can anyone suggest how I can get the form to goto the NewData added to the combobox?
Thanks,
Wendy