Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

Validate Subrecord Count Before Inserting Master

Avatar of DerryLyons
DerryLyons asked on
Microsoft Access
12 Comments1 Solution276 ViewsLast Modified:
This is probably straightforward, but I must be missing something.

Scenario:
 * Master form (one record per school) to enter test data (bound to a school location code)
 * Combo drop-down box shows schools without scores (OnCurrent runs a Requery to repopulate the combo box after each new record)
 * After choosing school, Sub form to enter test types/scores

Problem:
User enters new master record, chooses the school, then skips entering the test scores on the subform. Since the master record exists, moving to a new record (requery) correctly drops it from the combo box, and the user asks "how come I can't see school xx?"  (Sometimes error trapping is better than constant reminders.)

THE QUESTION... which form action is appropriate to validate that there are sub-records before moving to the next master record? (Code is below, and logic works, just can't get the order right...) Since the user can bounce between master and subform, I really want to catch it when they move to a new master record.

Thanks!

Dim subreccount As Integer
    subreccount = Forms!Workspace![Workspace subform].Form.RecordsetClone.RecordCount
    If (subreccount = 0) Then
      MsgBox ("Please choose a different school or paste the P223 data")
      Me.Undo
    End If