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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

find record - I'm Lost

Status
Not open for further replies.

skate

Technical User
Nov 29, 2002
65
CA
i need some help with some coding (as I know very little)
i just need a little procedure that will check if a record has already been entered (check by comparing that two fields of formA and the two fields of formB are equal). if not, i want to continue to check the rest of the records in the form until none is found then i will add a new record. FormA & formB are subforms of Form1. I don't quite get the whole concept of recordsets and recordsetclones, etc., but is it possible to still check the records even if what is displayed in FormB is based on Form1's index?
 
Recordsets or a good query with a DLookup are definitely the way to go. Give us some more information like how the two subforms are related and what you are trying to accomplish and I'm sure one of us will give you a solid example. Also, your version of Access will be helpful.
 
i am using access2000

My main form1 is based on a table that has a list of jobs, description & Index.
FormA displays all records with the same Index (diplays all employees working on that particular job for each month-# of records can vary). Right now it is set up to scroll thru these records and create a tally of job hours for each employee. Basically when the employee name changes the tally ends and the value is entered into FormB. I have this part working, the only thing is each time the form loads up and loops thru the records I have it set to create a new record in FormB to enter the tallied value --> as a result I get multiple values. FormB displays all it's records w/ the same Index as Form1 (all employees working on that particular job). I think that if i just creat a function that checks whether there is an existing record (based on two field value criteria), then I would only create a new record based on this result.

Confusing? Does this help?
 
Why not make a query that sums the number of hours and use it as the source for formB? Then on the after update event of FormA, requery FormB.

Alternately, you could make an appropriate unique index on the Table behind FormB and trap the error...

Or you could use a recordset clone to test if the record exists... Unfortunately I don't have time at the moment to write that code.

A Dcount would work too, but it is likely less efficient than using an already declared recordset repeatedly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top