Re: Form will not requery no matter what
- From: "Albert D. Kallal" <PleaseNOOOsPAMmkallal@xxxxxxx>
- Date: Sun, 18 Feb 2007 11:12:41 -0700
The problem is when you use the not-in-list, you are in the middle of a
controls event.....
the normal approach to add data is:
The easy way to do this is have ms-access do ALL of the work for you. So,
given that new data is the actually text you typed into the combo, then you
can do the following:
Private Sub Distributee_NotInList(NewData As String, Response As Integer)
if MsgBox("Do you want to add this value to the list?", _
vbYesNo) then
DoCmd.OpenForm "frmAddClient", , , , acFormAdd, acDialog, NewData
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
The above is ALL YOU need. You can see it is not much code.
Note that by setting response = acDataErrAdded, then ms-access does a
re-load, and a re-query of the comb box list for you. Also, ms-access will
ALSO re-load your form. In other words, quite
a bit of stuff happens to ensue that the combo box is re-loaded, and re-set.
The problem you have is that the combo box is operating on the CURRENT
form.
However, we can use our new found knowlege of the HUGE number of
things that setting acDataErrContinue does for us.
In your case, you HAVE to add the record INSIDE of this event, since the
AFTER UPDATE EVENT IS going to try and MOVE to this new record.
So, try the following:
If MsgBox("Not found, would you like to add this new reocrd?" & NewData,
vbYesNo) = vbYes Then
Me.RecordsetClone.AddNew
Me.RecordsetClone!Description = NewData
Me.RecordsetClone.Update
Response = acDataErrAdded
End If
note that you have to replace "Description" with the actually column that
your combo box does a search on. Remember, the value of
newdata IS NOT the bound column, but the column that you have for display
(they might be different). Useally you have your combo box return a id
value, but display/search on text values...so, keep this in mind...
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@xxxxxxx
.
- References:
- Form will not requery no matter what
- From: justme
- Form will not requery no matter what
- Prev by Date: Re: Ranking - dealing with ties
- Next by Date: Re: Ranking - dealing with ties
- Previous by thread: Re: Form will not requery no matter what
- Next by thread: Re: Form will not requery no matter what
- Index(es):
Relevant Pages
|
Loading