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

Required Fields Datasheet Form 1

Status
Not open for further replies.

grgimpy

Programmer
Nov 1, 2006
124
US
I have a master form with a child subform setup. This is a one to many relationship. I want to ensure all fields are being filled into each subform record before new records are added.

I would like to accomplish this without requiring the fields to be entered in the table properties.

I have looked at the OnCurrent event, but this only fires after the user has already moved to a different record. I do not want them to move to a different subform record until all fields have been entered in the current record.

The subform is in the datasheet view. What is the easiest way to do this?

Thanks
 
look at the forms beforupdate event. You can cancel this event if the required information is not provided.
 
Once I encounted this problem and I used the AfterUpdate event. That is, i allowed the user to leave the record to the next record and then I evaluate it for errors and bring him back to the old record if I find errors. And if in the process of moveing to the next record a new record is created I delete it.
 
PercyN,
Why would you do that? Seems overly complicated.
 
I will play with the beforeupdate event. Thanks for the input.
 

MajP is correct, this should go in the BeforeUpdate event for the form. Typical code would look something like this:
Code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
 If IsNull(Me.Control1) Then
   MsgBox "Control1 Must Not Be Left Blank!"
   Cancel = True
   Control1.SetFocus
 End If
End Sub

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top