Repost: Test Linked form for data

  • Thread starter Thread starter CJ
  • Start date Start date
C

CJ

This was originally posted on September 14, 2007. "Test Linked form for
data"

Hi Groupies

How can I test to see if a linked form, that might not be visible, has data?

My main form has a yes/no box that enables a button when it is set to yes.
The button opens a linked form. When the user moves to the next record, I
would like the main forms BeforeUpdate event to make sure that the yes/no
box is not set at No while there is data in the linked form for that record.

I have tried something like:

If Me.Form.frmVehicles.RecordsetClone.RecordCount > 0 And Me.CompanyVehicle
= False Then
Cancel = True
MsgBox "Please check vehicles", vbOKOnly
Me.frmVehicles.Visible = True
End If

When I test it, things just hang up. Any ideas?
 
Never mind, I actually figured it out, I was missing the WITH portion: FYI

Private Sub Form_BeforeUpdate(Cancel As Integer)

With Me![frmVehicles].Form

If .RecordsetClone.RecordCount > 0 And Me.CompanyVehicle.Value = False
Then
Cancel = True
MsgBox "Please Delete Vehicles If Not Needed", vbOKOnly, "Vehicles
Listed"
Me.frmVehicles.Visible = True
Me.CompanyVehicle.Value = True
End If

End With

End Sub
 
Back
Top