Question about Forms

jukus

Registered User.
Local time
Today, 18:14
Joined
Jan 9, 2008
Messages
52
Not sure if this is possible, but I was wondering if there is a way to may the records in a form read only after they have intially been saved.

My dilema is this. I created a database for an apartment complex that you enter info into. foe apartments, thus rendering all of the paperwork needed once you hit a print button. The form has a main form in which you select the apartment, employee entering info, etc. It also contains 6 subreports for everything to tenants, co-signers, etc. The problem we are having are the employee hat enters the info and does all of the work gets commission for the rental, and there seems to be a problem of some employees going in and changing the employee to them so they receive the commission. So I was wondering if I could make the main form read only after initial entry and allow the subform to be edited if needed.

Thanks for any input.
 
When a user goes to this record, if the employee name is filled in already, this will lock the employee name textbox and prevent it from being changed, while leaving other firlds to be edited:
Code:
Private Sub Form_Current()
  If IsNull(Me.EmployeeName) Then
    Me.EmployeeName.Locked = False
  Else
    Me.EmployeeName.Locked = True
  End If
End Sub
 
Last edited:
Thanks I will give it a try. Where exactly do you place the code?
 
As the title of Missinglinq's code sugests it goes in the ON Current event of the form.
 
That doesn't seem to work, but it may be because you select the employee from a combo box that then fills in the first name and last name. I wonder if the code to copy the name in the name textboxes overrides the code to lock the text boxes. I opened the vba editor and went to the code for the form and copied and pasted the code and changed the EmployeeName to EmployeeFirstName at the beginning. If I select another name from the combo box it then fills the textboxes with the new selection.

Will Getting rid of the combo box and simply having them type in there name solve this issue or should it still work with the combo box.

Thanks for the help.
 
It'd have helped if you've given this info in your original post! Just lock the combobox as well!

Code:
Private Sub Form_Current()
  If IsNull(Me.EmployeeFirstName) Then
    Me.EmployeeFirstName.Locked = False
    Me.EmployeeLastName.Locked = False
    [B]MeComboboxName.Locked = False[/B]
  Else
    Me.EmployeeFirstName.Locked = True
    Me.EmployeeLastName.Locked = True
    [B]MeComboboxName.Locked = True[/B]
  End If
End Sub
 
Sorry about that. Didn't think about that originally. Thank You for the help. This seems to be working and should solve the problem.

Thank You again for the help.
 

Users who are viewing this thread

Back
Top Bottom