I am trying to adapt the attached code soit can be used by more than one form. However, I don't seem to get teh function to recognize the name of the form.
Public Function fntDisableControls(strFormName As String)'If the claim is closed, lock the controls so changes cannot be madeDim frmName As FormfrmName.Name = strFormName'''frmName.CmdScans.SetFocusDim ctl As Control For Each ctl In frmName.Controls With ctl Select Case .ControlType Case acTextBox, acListBox, acComboBox .Locked = True .BackColor = 15461355 Case acCheckBox .Enabled = False .Locked = True End Select End With Next ctl'Me.SubFrmGLdata.Enabled = FalsefrmName.LblLocked.Visible = TruefrmName.CmdUnlock.Visible = TrueEnd Function
Public Function fntDisableControls(strFormName As Form)
Send the form itself as a parameter, instead of the name.
0
ssmith94015Author Commented:
That seems to work now. Also I can use ME rather than having to explicitly name the form wherever it is used.
Sandra
0
ssmith94015Author Commented:
This is what I have now.
Public Function fntDisableControls(frmName As Form)'If the claim is closed, lock the controls so changes cannot be madefrmName.CmdScans.SetFocusDim ctl As Control For Each ctl In frmName.Controls With ctl Select Case .ControlType Case acTextBox, acListBox, acComboBox .Locked = True .BackColor = 15461355 Case acCheckBox .Enabled = False .Locked = True End Select End With Next ctl'Me.SubFrmGLdata.Enabled = FalsefrmName.LblLocked.Visible = TruefrmName.CmdUnlock.Visible = TrueEnd Function
Jim Dettman (Microsoft MVP/ EE MVE)PresidentCommented:
Just for clairty, I would change this:
Public Function fntDisableControls(frmName As Form)
to
Public Function fntDisableControls(frm As Form)
as your really not passing the name, but a form reference. frmName implies a string like you first had (which would have worked BTW, but a form reference is better by far).
Jim.
0
Question has a verified solution.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.
One of a set of tools we're offering as a way of saying thank you for being a part of the community.