displaying existing records or new if they don't exist in a form

sheederj

Registered User.
Local time
Today, 23:15
Joined
Jul 26, 2001
Messages
27
I have a form where the primary key is called ptid. When I have someone entering data, I would like the form to display the record for that person if they already exist, but if they don't to just be blank. In other words, the data entry person is entering ptid 123, if 123 is not already in the database, I would like the form to just be blank. If however 123 is already in, I would like the form to display that record. Anyone have an easy solution? Thanks!
-Jeanelle
 
Use a combo box whose control source is set to ptid. Look up working with forms and controls from the Solutions database. Available from MS download.
 
that didn't seem to work, when i click on the down arrow, there is nothing in the list. Also, how exactly do i get to the solutions database?
Thanks for your help.
 
Hi there

If you still need help - I usually use apply filter to do what you need.

You need to put an unbound control at the top of your form for a " dummy entry"

Your user enter the ptid in this field then in the after update event of the dummy control you add the code
docmd.applyfilter,"[ptid]=" & me.dummycontrol name

You can fancy this up by using an if statement eg.
x=dcount ("*",Tablename,"[ptid]=" & me.dummy)
if x > then 0 then 'if the record exists
docmd.applyfilter.........
else
docmd.gotorecord acnewrec
realptid.setfous
end if

this uses a count to ascertain if the record exists - if it does it filters it out and if it doesn't it prepares to add a new record.

Hope this helps

Marion
 

Users who are viewing this thread

Back
Top Bottom