Click to See Complete Forum and Search --> : How to control when a user changes the control of the text box???
Anita
Nov 23rd, 1999, 01:45 AM
I am making an user interface where a user can search the database for a particular record.My problem is when the record is displayed and if the user changes the contents of any text boxes I need to save the changes.I want to display the save button as soon as the user makes any changes.I have created a flag .Where should I put the code .If I put it in the lost focus event or in the change event, it is not working.It is automatically going to
that event.Please help me.
Serge
Nov 23rd, 1999, 01:52 AM
Use your Flag on Text1_Change event.
Option Explicit
Private m_bFlag As Boolean
Private Sub Text1_Change()
b_bFlag = True
End Sub
------------------
Serge
Software Developer
Serge_Dymkov@vertexinc.com
Access8484@aol.com
ICQ#: 51055819 (http://www.icq.com/51055819)
Anita
Nov 23rd, 1999, 02:13 AM
Thanks for your reply.But I need to set the flag for each textboxes, right?As the user can change the context of any text boxes.Where do I put the code to display the save button.Please help!!!!!!!
Chris Perrin
Nov 23rd, 1999, 02:54 AM
What I do is make it so that everytime the record is moved (MoveNext, MovePrevious, MoveFirst, MoveLast) I call a routine that saves the record (usually called the creative name SaveData) This removes the necessity of using the flag as all people have to do make corrections and then move to the next record.
Have you considered a control array? Then you write the flag change code once and be done with.
Also, write the routine to make the Save button appear and disappear in a separate subroutine called when the flag is changed.
If that does not help, tell me.
Anita
Nov 23rd, 1999, 03:45 AM
Thanks for the reply.I have created a control array now and in the change event i have set the flag to true.Now I have created
two routines displaymode(without the save button) and editmode( with the save button).My question is from where I call this routine.If i call it from the change event of the textbox, editmode is becoming the defaultmode.
please reply.
MartinLiss
Nov 23rd, 1999, 04:57 AM
By "...editmode is becoming the defaultmode" I assume you mean that as soon as you see your form, that the "Save" button is visible, and you don't want it to be. What is its initial state? If Visible is True, make in False. If it's False, then put a breakpoint in the Change event of the textbox and see what is happening that is causing the change event to happen. Then if it's something you can easily check for in your change event code, do so and don't display the "Save" button. By the way, even if the above does not correct your problem, I have another suggestion and that is to use enabled/disabled for your save button rather that visible/invisible.
------------------
Marty
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.