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

Edit Database Field Technique From A Form 2

Status
Not open for further replies.

Skittle

ISP
Sep 10, 2002
1,528
US
I have created a form that displays one record of a database. My form has an add, delete, next and previous button and I can move around the table to maintain it.

It strikes me as bad programming to allow a user to edit any field in a record without the user first clicking on an 'edit' button to change the text fields from 'display only' to 'display and modify'. There is a property of the text box called 'Locked' which can be used to prevent a user overtyping a textbox value and I suppose unlock it when I hit an 'edit' button.

Is this the standard method everybody uses or is the standard to let people overtype textbox fields and then issue a warning 'Save Changes?' once the user tries to move off the record or close the form?



Dazed and confused
 
Yes there is such a property. to prevent the user from editing the data in a text box,

Code:
Text1.Locked = True

To allow editing,

Code:
Text1.Locked = False

If you want to use and edit button to toggle the
Code:
.Locked
property then try this,

Code:
Private Sub Command1_Click()
  Text1.Locked = Not Text1.Locked 
End Sub

Take Care,

zemp

"If the grass looks greener... it's probably because there is more manure."
 

Would
[tt]
Private Sub Command1_Click()
Me.AllowEdits=True
End Sub [/tt]

work so you dont have to touch every single control?
 

>or is the standard to let people overtype textbox fields and then issue a warning 'Save Changes?

This is the method which I use and prefer - It should be done anyways (whether they first click EDIT or not)

 
I use an edit button, and (being much lazier than LostInCode) I don't allow any changes unless the user hits same. (When the user is in edit mode, I make a save and a cancel button visible.) To unlock text boxes, I do:
For Each ctl in me.controls
if TypeOf ctl is TextBox then
ctl.Locked = Not ctl.Locked
end if
Next
This works to either lock or unlock all the text boxes on a form.

HTH

Bob
 
BobRodes:

Thats the way I have done it in the past on the AS400 but I woundered if it might not be the accepted way for a windows program.

LostInCode:
I think the 'Save Changes' is certainly essential if users can overtype fields directly in a form.

Dazed and confused
 
It's an accepted way if the users will use it! In my experience, it works out. In non-edit mode, I have the 4 directional buttons, as well as add, edit, delete, and exit, and sometimes locate if it's appropriate to the situation. In edit mode, I have save and cancel. I make the save and cancel buttons visible in edit mode, and the others invisible, the reverse in non-edit mode, and I don't allow users to overtype. Furthermore, I don't generally use binding, preferring to write a proc to handle binding myself.

Bob
 
Dear Bob

I was interested to read you're post, especially about not binding controls. Could you give me a quick rundown on how this can be done. I think it's the answer to my problem.

thanks in advance
Toby
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top