Results 1 to 6 of 6

Thread: How to control when a user changes the control of the text box???

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 1999
    Posts
    36

    Post

    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.

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    Use your Flag on Text1_Change event.

    Code:
    Option Explicit 
    
    Private m_bFlag As Boolean
    
    Private Sub Text1_Change()
       b_bFlag = True
    End Sub
    ------------------

    Serge

    Software Developer
    [email protected]
    [email protected]
    ICQ#: 51055819


  3. #3

    Thread Starter
    Member
    Join Date
    Nov 1999
    Posts
    36

    Post

    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!!!!!!!

  4. #4
    New Member
    Join Date
    Feb 1999
    Posts
    10

    Post

    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.

  5. #5

    Thread Starter
    Member
    Join Date
    Nov 1999
    Posts
    36

    Post

    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.

  6. #6
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Post

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width