After_Update not working after Add

SDLevy

Registered User.
Local time
Today, 14:02
Joined
Jul 1, 2002
Messages
14
Hello,

I've cobbled together some code to do the following:

1. Look for a member in the combo box
2. If not found, go to a data entry form and add new member
3. Manually close data entry form with a button
4. Return to main form
5. The new name is now in the combo box

But when the user selects the newest addition they can't get to that record. Usually they tab to the new record, now it just goes to the first one.

If the form is closed and reopened then it works fine, so is that what I need to put in the code?

I was going to show the code for each step, but was afraid it would be too much. I've included step 1.

Thanks Susan



1. Private Sub cboFindName_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[PeopleID] = " & Str(Me![CboFindName])
Me.Bookmark = rs.Bookmark
CboFindName.Value = ""
End Sub


and

Private Sub cboFindName_NotInList(NewData As String, Response As Integer)
Dim CR As String

'Where Current form is where the combo box is that this code is assigned to

CR = Chr$(13)

' Exit this subroutine if the combo box was cleared.
If NewData = "" Then Exit Sub

' Confirm that the user wants to add the new record

Msg = "'" & NewData & "' is not in the list." & CR & CR
Msg = Msg & "Do you want to add it? "

If MsgBox(Msg, vbQuestion + vbYesNo) = vbNo Then

' If the user chose not to add a record, set the Response
' argument to suppress an error message and undo changes.

Response = acDataErrContinue

' Display a customized message.

MsgBox "Select another record.", vbOKOnly, "Record Not Added"

Else

' If the user chooses to add a new record, open the Add Record Form
'also set the response argument to suppress the error message

Response = acDataErrContinue
DoCmd.OpenForm "frmAddNewPerson", , , , acFormAdd, , NewData
Forms!frmAddNewPerson!LastName = NewData

Me.CboFindName.Value = 0
End If

End Sub
 
Thanks for the link, but not quite the solution

Hi,

Thanks for the link, but it didn't quite do the trick. I had used this link before I wrote to try and fix this . I am guessing I've set this up "wrong", but I think I'll leave it for now.

I am trying to add a new person in the Membership table from the Membership table. I've ended up copying the initial form so if it is not found in the combo box it opens the "copy" and the user can add the new person. All of that works fine. Since the name appears after they return and close the original form, it is doable.

And for now, I think that is the best I can manage as it has been a long week of trying to tweak different things and nothing is coming close.

But thank you for your help.

Susan
 
It sounds like you have it! Adding a name to the combo box that does not exist in the Membership table should open your membership data entry form with the name you entered into the combo box and ready for the user to enter any other relevant data. When they close the form their data should show up in the combo box and that sounds like what you are getting. It sounds from your description that you have it working.

Good luck!

Jack
 

Users who are viewing this thread

Back
Top Bottom