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

Keeping sub form locked until data entered on main form 2

Status
Not open for further replies.

WallT

Vendor
Aug 13, 2002
247
US
I'm trying to keep my sub form locked until user enters thier initials on the main form. I tried the following in the Form_Current, but just don't have enough experience with vb to get it right. Any help would be great.

If Me.UserInitials & ""="" Then
[frmDataEntry].Form.Enabled = False
Else
[frmDataEntry].Form.Enabled = True
End If
 
try (replace [blue]sfrm[/blue] by the name of your subformcontrol):

Code:
Private Sub Form_Current()
If IsNull(Me.UserInitials) Or Me.UserInitials = "" Then
Me.[blue]sfrm[/blue].Enabled = False
Else:
Me.[blue]sfrm[/blue].Enabled = True
End If

End Sub


HTH,
fly

[blue]Typos, that don't affect the functionality of code, will not be corrected.[/blue]

Martin Serra Jr.
[blue]Shared Database_Systems and _Applications across all Business_Areas[/blue]
 
WallT
You're on the right track. A subform is a control on the main form.

The correct way to reference a subform is
Forms!MainFormName!Form.SubFormName

So try code something like
Code:
If IsNull(Me.UserInitials) Then
   Forms!MainFormName!Form.[frmDataEntry].Enabled = True
Else
   Forms!MainFormName!Form.[frmDataEntry].Enabled = False
End If

Tom
 
WallT
If the code I offered isn't quite right, it means I got the "dot" (.) and the "bang" (!) operators mixed up.

It should be...
Code:
If IsNull(Me.UserInitials) Then
   Forms!MainFormName.Form![frmDataEntry].Enabled = True
Else
   Forms!MainFormName.Form![frmDataEntry].Enabled = False
End If

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top