Hi i have two tables namely products and sales. both have fields called 'product name' and 'product ID'.i have also created two forms for inserting data in to the tables. on the sales form the product and product id fields are connected to products table as the data source. some users when entering data into the sales table and find that the product name is not there, lets say the product has not been added in the products table so its empty. they decide to type in directly, this leaves my products table empty yet the sales table appear to have products. how do i solve that by only allowing them to select from the combo box but not to type in? regards
How to only allow users to select from combo but not type in
Collapse
X
-
Tags: None
-
There is a "limit to list" property. Set that to "yes" and new entries cannot be made.
There is also an event, "On Not in List", which allows you to execute some program code in the event they type in something that is not in the list. Using that, you could automatically add an new item to both tables or force some limits on what they add.
Jim -
Thanks so much jim, i,ve tried the limit to list and works fine. by the way kindly give me the code to type in the event so that after up date the same should also be added to the other table, i,m really a newbie in VB programming. tables are product and sales. fields in the two tables are [product name] and [product ID]. regrads, gerryThere is a "limit to list" property. Set that to "yes" and new entries cannot be made.
There is also an event, "On Not in List", which allows you to execute some program code in the event they type in something that is not in the list. Using that, you could automatically add an new item to both tables or force some limits on what they add.
JimComment
-
It would be something like this
Code:dim dbs as dao.database (I'm assuming DAO) dim rsProducts as dao.recordset on error goto ErrorStuff set dbs = currentdb set rsProducts=dbs.Openrecordset("tblProducts",dbopendynaset,dbseechanges) rsproducts.addnew rsproducts![product ID]=me!newproductid rsproducts![Product name] = me!newproductname rsproducts![other stuff as needed] = me!othernewstuff rsproducts.update rsproducts.close set rsproducts= nothing set dbs = nothing exit sub ErrorStuff: resume next ' or display message or whatever u wantComment
Comment