Activating a subform (1 Viewer)

sal

Registered User.
Local time
Yesterday, 19:01
Joined
Oct 25, 2009
Messages
52
I am trying to develop an application for others to use but every so often a user locks up the main data entry form by entering a value into the sub form before they have entered the data into the main form that creates the record the subform data will be linked to.:eek:

I would like to deactivate the subforms until data is entered in the main form and the Auto Number ID is updated.;)

I have tried setting the control Enabled Property to NO then


Private Sub Form_AfterUpdate()
Me.TabCtl141.Enabled = True
End Sub

But it prevents the user from using the control on previously entered records and doesn't work until leaving the main form. Then the subform remains active when the user proceeds to the next New Record.:(
 
Last edited:

boblarson

Smeghead
Local time
Yesterday, 19:01
Joined
Jan 12, 2001
Messages
32,059
In the main form's On Current event you could put this:

Code:
Me.YourSubformControlName.Visible = Not Me.NewRecord
Where YourSubformControlName is the name of the subform control which HOUSES the subform on the main form (not the subform name itself).

And that way it won't show it until there is a valid record in the main form.
 

sal

Registered User.
Local time
Yesterday, 19:01
Joined
Oct 25, 2009
Messages
52
Thank you Bob. This works well, but I have to back out ot the record then re-enter it before the control appears. Should I requery the form on update?
 

sal

Registered User.
Local time
Yesterday, 19:01
Joined
Oct 25, 2009
Messages
52
I put this on OnDirty:

Dim lngRecNo As Long
lngRecNo = Me![ID]
Me.Requery
Me![ID].SetFocus
DoCmd.FindRecord lngRecNo, acEntire, , acSearchAll

And it seems to work as Needed. I used Enabled instead of Visible just to let the user know the Control is there. Hopefully, I have this solved.

Thanks Bob.
 
Last edited:

Users who are viewing this thread

Top Bottom