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!

Ensure data is entered into a subform field.

Status
Not open for further replies.

andagain

Technical User
May 28, 2004
25
GB
Hi there people,

I want to make sure my user fills in a particular control (duration) on a continous record subform (interactionssubform) within my form. The subform is on another page if that has any implications....

I just want to stop them going to a new or another record until they have entered some data into duration on the subform....I already have some code in the BeforeUpdate of my main form to make sure the user does not leave a field 'Registrationdate' (on the main form) empty......can I just put some more similar code into the same event as below?.....which doesn't seem to work for me...or is there more to it than that?

Private Sub Registrationdate_BeforeUpdate(Cancel As Integer)
If Trim(Me.Registrationdate & "") = "" Then
MsgBox "Please enter a Registration Date for this client. Thank you."
Cancel = True
End If

If Trim(Forms!Interactionssubform!Me.Duration & "") = "" Then
MsgBox "Please enter a duration for this client. Thank you."
Cancel = True
End If
End Sub

Can you do that...have two If Then thingys in one event of  a form?
Am I on the right track or completely off the ball? ? ? ?
Still haven't had any time to learn this stuff...just getting by....
Thanks for any help.

Andrew.
 
Replace this:
If Trim(Forms!Interactionssubform!Me.Duration & "") = "" Then
By something like this:
If Trim(Me![name of Interactionssubform control].Form!.Duration & "") = "" Then

You may also consider make the field required in the table design view.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top