I understand, it is one of the hardest to get your head around.
This is untested, but should then move to the newly added record
If MsgBox("'" & NewData & "' not on file. Enter as new?", vbOKCancel,
"Add New Competitor?") = vbOK Then
'Remove new data from combo box so control can be requeried
'After the Add Team form is closed
stDocName = "Master Input"
DoCmd.OpenForm stDocName, , , , acFormAdd, acDialog, NewData
'continue without displaying default error message.
Response = acDataErrAdded
Me.Requery
With Me.RecordsetClone
.FindFirst "[Primary Key Field] = " & NewData
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End With
Else
Response = acDataErrContinue
End If
--
Dave Hargis, Microsoft Access MVP
CD Tom said:
I tried putting that into the not in list event and it still doesn't work.
Here's what I have in the event
If MsgBox("'" & NewData & "' not on file. Enter as new?", vbOKCancel,
"Add New Competitor?") = vbOK Then
'Remove new data from combo box so control can be requeried
'After the Add Team form is closed
DoCmd.RunCommand acCmdUndo
stDocName = "Master Input"
DoCmd.OpenForm stDocName, , , , acFormAdd, acDialog, NewData
'continue without displaying default error message.
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
Do I place that right after the last end if? Sorry to sound so stupid but
I've always had a problem with the not in list event.
Klatuu said:
The calling form.
--
Dave Hargis, Microsoft Access MVP
:
does this go into the master input form or the one that calls the form?
:
Howdy,
The problem is you have updated the table, but not the form's recordset.
That is why you don't see it in the form.
To get it into the form's recordset, you need to do a requery:
Me.Requery
Simple enough, but, Now your form jumps back to the first record in the
recordset. So, what you have to do is keep track of the key of the current
record, do the requery, then reposition the form recordset to the original
current record.
Application.Echo False
lngRecId = Me.txtPrimeKey
Me.Requery
With Me.RecordsetClone
.FindFirst "[KeyField] = " & lngRecId
If Not .NoMatch Then
Me.Bookmark = .Bookmark
End If
End If
Application.Echo True
Note: The Echo may not be necessary. It is only to prevent the screen
jumping around. If you do use it, be sure it will get turned on in your
error handler.
--
Dave Hargis, Microsoft Access MVP
:
I have a combo box that is set for a not in list event if the customer that
the user types in isn't in the current db. When the not in list event is
entered the user is presented with a message if they want to add the user?
If they respond yes the I bring up the master input form. The user then
fills out the form and then exits, I'm back at the original form but the new
customer isn't available to display, if I exit the form and then reenter it
the new customer is there. What I would like to have happen is when the user
leaves the master input form the new customer is displayed on the original
form. How do I make this happen. Thanks for any help. I always get great
answers here when I'm stumped.
Tom