Form with SubForm

Andrew Thorpe

Registered User.
Local time
Today, 15:02
Joined
Apr 18, 2009
Messages
59
With a simple form and datasheet subform, if the user tries to create a new record in the subform before a record has been created in the parent form, then Access displays a message which may not be understood by the user. I would like to handle it so that I can give a more helpful message. However, I'm not sure where to put such code. I have written some, but Access jumps in before my code gets a chance.
 
Thank you. Yes, I'll try that and using the Before event, I should get there before the auto message. Many thanks.
 
I would simply disable the subform control unless you have a value in the appropriate control on the main form:

Code:
Private Sub MainFormControlName_AfterUpdate()
 If Not IsNull(Me.MainFormControlName) Then
  ActualSubformControlName.Enabled = True
 Else
  ActualSubformControlName.Enabled = False
 End If
End Sub

Private Sub Form_Current()
 If Not IsNull(Me.MainFormControlName) Then
  ActualSubformControlName.Enabled = True
 Else
  ActualSubformControlName.Enabled = False
 End If
End Sub
Note that ActualSubformControlName needs to be the name of the subform control, which may or may not be the same as the name of the form the subform is based on.
 
Many thanks. Much appreciate your help. I'll give it a try. Andrew
 

Users who are viewing this thread

Back
Top Bottom