I have a form that I would like to do the following in the VBA OnOpen or OnLoad (I'm not sure which would be appropriate) event:
Count the number of records in tblScheduledEmployees.lngScheduleID that have records that match the current field lngScheduledID on the form.
IF the count of records is LESS THAN the value of strManualNurseCount then I want to run a query (qryAddContractor) to add records UNTIL the count of records in tblScheduledEmployee EQUALS strManualNurseCount.
IF the count is EQUAL or GREATER THAN, then move to the next unique number in the recordset
I would like this loop to run for each unique number of the field lngScheduleID in the recordset on the form.
I have attached a copy of the database with the relevant form and tables.





