Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to: on not in list, add to table then select

Status
Not open for further replies.

PLiNk

IS-IT--Management
Apr 12, 2003
32
NO
How would I do this in an effective manner?

To be more specific I have a table with a lot of names in it, but the primary key is a autonumber. I have a table that stores this
NameID, but to make things easy for the people using the database I would like them to typein a name, and if it doesn't exist already they add the name to the table, and then select it and move on in one go.

The help function told me to use the On Not in List function found under the event tab at preferences.
Can anyone help me with actual code to write under the On not in List?

James
 
KenReay has made a faq available for this, take a look at that, and report back if you have problems (faq702-4283)

Roy-Vidar
 
PLink,

Do you now use a commbo box pick list to choose the name? You were not clear on this point. If not, I would just use an umbound textbox on your form and enter the name. Then the following code will do what you wish.

DIm rs as dao.database
' requires ms DOA 3.?? reference in Tools.

set rs = me.recordset
rs.movelast
rs.movefirst
do while not rs.eof
if me.txtNewName = rs("Names1") then

goto around:
endif


rs.movenext
loop
rs.addnew
rs("Names1") = me.txtNewName
rs.update

around:
rs.close
set rs = nothing

rs.close
set rs = nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top