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

Lock/Edit Records in Main form and Subform

Status
Not open for further replies.

millrat

Technical User
Joined
Dec 23, 2003
Messages
98
Location
US
Here's my dilemma...I have a Main form with a Master-Child Subform. I want to be able to lock the records in both forms (ie no edits) and still lookup records using a combobox. When I want to edit both forms I want to be able to use a command button (password protected) to filter the current record and allow edits on both forms.
Any tips on how to do this would be greatly appreciated.
Thank you
millrat
 
This is what I would do, but maybe someone else has a better idea:

First I would go through and lock all fields in the form except for the combo field.

Then on the command button, I would have the following code:
Private Sub Command2_Click()

If Me.txtPword = "yourpassword" Then
DoCmd.OpenForm "form_to_be_opened"
DoCmd.Close acForm, "Password_frm"
Me!field1.Locked = False
Me!field2.Locked = False
Me!field3.Locked = False
Me!field4.Locked = False
Else
MsgBox "Incorrect Password", vbOKOnly, "Password Error"
DoCmd.Close acForm, "FrmPassword"
End If

End Sub

Does this help,


Jerome Benton
JERPAT Web Designs
GOD Is Good All The Time!!!
 
Correction:
Lock all fields of the mainform and subform

This is how you reference a subform:
Me![SubFormName].Locked = False
Me![SubFormName]![SubFormField].Locked = False

When you reference a subform you have to reference the subform first then reference the subform and field next.

Jerome Benton
JERPAT Web Designs
GOD Is Good All The Time!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top