NotInList

  • Thread starter Thread starter Ivor Williams
  • Start date Start date
I

Ivor Williams

?Long story short, I've been away for a while. I originally posted the
following last September and I never got an opportunity to check for
responses. If someone could answer it now, I'd appreciate it.

I have a combo box on a form which uses as a record source a table. The
Limit To List property is set to yes. I have another form for new entries
which I want to open whenever an entry in the combo box does not match
anything in the list.
Then the user can enter the necessary information on the new entry form and
close it, making the new entry available in the combo box. Can someone
please suggest some code to make this work.
 
?Long story short, I've been away for a while. I originally posted the
following last September and I never got an opportunity to check for
responses. If someone could answer it now, I'd appreciate it.

I have a combo box on a form which uses as a record source a table. The
Limit To List property is set to yes. I have another form for new entries
which I want to open whenever an entry in the combo box does not match
anything in the list.
Then the user can enter the necessary information on the new entry form and
close it, making the new entry available in the combo box. Can someone
please suggest some code to make this work.

Something like:

Private Sub combobox_NotInList(NewData As String, Response as Integer)
DoCmd.OpenForm "yournewentryform", OpenArgs:=NewData,WindowMode:=acDialog
Response=acDataErrAdded
End Sub

In the form's Open event you would set the DefaultValue of the field to the
OpenArgs value, so the user can accept what the user typed into the combo box
or change it. This code assumes that there will always be a new value added to
the combo, which might not always be the case.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 
As John suggested near the end of his response, there will not always be a
new value added. How should the code be written in this case?

"John W. Vinson" wrote in message

?Long story short, I've been away for a while. I originally posted the
following last September and I never got an opportunity to check for
responses. If someone could answer it now, I'd appreciate it.

I have a combo box on a form which uses as a record source a table. The
Limit To List property is set to yes. I have another form for new entries
which I want to open whenever an entry in the combo box does not match
anything in the list.
Then the user can enter the necessary information on the new entry form and
close it, making the new entry available in the combo box. Can someone
please suggest some code to make this work.

Something like:

Private Sub combobox_NotInList(NewData As String, Response as Integer)
DoCmd.OpenForm "yournewentryform", OpenArgs:=NewData,WindowMode:=acDialog
Response=acDataErrAdded
End Sub

In the form's Open event you would set the DefaultValue of the field to the
OpenArgs value, so the user can accept what the user typed into the combo
box
or change it. This code assumes that there will always be a new value added
to
the combo, which might not always be the case.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/Forums/en-US/accessdev/
http://social.answers.microsoft.com/Forums/en-US/addbuz/
and see also http://www.utteraccess.com
 
Ask the user if they want to enter a new record, before you open the form
that allows them to do so... you can use a MsgBox, or you can display a form
(could be popup or dialog) that tells them no record was found, and gives
them the choices of (1) ignore or (2) I want to add a new record.

--
Larry Linson, Microsoft Office Access MVP
Co-author: "Microsoft Access Small Business Solutions", published by Wiley
Access newsgroup support is alive and well in USENET
comp.databases.ms-access
 
Back
Top