Lock subform if combo in main form is null (no selection)

J

JK

How do I prevent a user in Access03 from gaining access to a subform if a
selection in the mainform combo was not made?
 
A

Arvin Meyer [MVP]

JK said:
How do I prevent a user in Access03 from gaining access to a subform if a
selection in the mainform combo was not made?

The easiest way is (for new records) disable the subform by default until
the combo box selection is made. First select the subform, and in the
property sheet, disable it. Then:

Sub Form_Current()
If Me.NewRecord = False Then
Me.SubformControlName.Enabled = True
Else
Me.SubformControlName.Enabled = False
End If
End Sub

Sub MyCombo_AfterUpdate()
If Me.MyCombo <> "" Then
Me.SubformControlName.Enabled = True
End If
End Sub
 
J

JK

Thx for the response, but I'm not sure this will work. The combo is in a tab
control on the main form. I'm trying to prevent people from using a subform
if no selection has been made to the combo on the main form.

Your after update event for the combo on the main form does not reference
the field(s) in the subform. I get an error. Can I do something like -
instead of Me.Field, Forms![Subform].[SubformField]? I'll try it...

I also want to make sure people can make changes to the subform anytime so
long as a selection to the combo has been made on the main form. Which means,
it will not always be a new record. Will this work if the user goes back to
this record after creating it to make a change or add a record to the subform?

Thx again for your help. Me greatful.
 
J

JK

My bad - I missunderstood your instructions. I've been able to make it work &
it works great!!! Thx for your help!!!

Jason
 
Top