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!

Lock / Disable form Bound to a table

Status
Not open for further replies.

jdspinelli

Programmer
Jul 9, 2010
20
US
Good Morning:

I have a form bound to a table. A combo box is used to select a record. If a record is not selected, I want to lock/disable the controls on the form until a record is selected. What is the best Event Property to base the Disable/Enable logic on?
Thanks
Joe
 
How are ya jdspinelli . . .

However you do this you'll need code to perform the locking/unlocking of controls. What follows is a standard routine to handle this. An arguement determines the locking state (True/False). To supplement the code, in form design view you add an identifying character to the [blue]Tag[/blue] property of each control you desire to control ([blue]you can group select to perform this[/blue]). The code currently uses the question mark (?) for this. Note when you enter the character in the property, [purple]do not use any quotations[/purple].
Code:
[blue]Public Sub locControls(loc As Boolean)
   Dim ctl As Control

   For Each ctl In Me.Controls
      If ctl.Tag = loc Then ctl.Locked = loc
   Next

End Sub

[green]'To lock controls  : call locControls(True)
'To unlock controls: call locControls(False)[/green][/blue]
Set the property to false in design view so the form opens read only.

The question is what will determine turning the locks back on once a selection is made?

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Hey AceMan1,

I am doing very well and hope you are doing the same!

Thanks for the Tag and lock notes. I will use and implement.

Have a great day!
Joe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top