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

lock controls except for new records 1

Status
Not open for further replies.

JacobTechy

Programmer
Apr 14, 2005
181
US
I am developing a form using ms access 2002 and vb for apps where production workers enter in work orders. Once workers enter the work order the controls (textbox, combobox) become locked so that they wont edit the data. I do have a button called managers edit where the manager can input a password to allow him to edit the past entered records. My problem is that when the worker wants to add a new record those controls are locked also. How can I make it where the new records that will be entered do not have locked controls. Below is my code to lock the controls.

Code:
Private Sub Form_Open(Cancel As Integer)
Dim ctl As Control
For Each ctl In Me.Controls
    If TypeOf ctl Is TextBox Then
       ctl.Locked = True
    End If
    If TypeOf ctl Is ComboBox Then
       ctl.Locked = True
    End If
Next
End Sub
 
JacobTechy,
You might try something like this.
Code:
Private Sub Form_Current()
If Me.NewRecord Then
  'Unlock the controls
Else
  'lock the controls
End If
End Sub

Hope this helps,
CMP

(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top