Alpha Video Training
Results 1 to 16 of 16

Thread: <form>.new_record() and hide combo. Is this a bug?

  1. #1
    Member
    Real Name
    Dan Hooley
    Join Date
    Jan 2008
    Location
    Washington (State)
    Posts
    343

    Default <form>.new_record() and hide combo. Is this a bug?

    Here is what happens...

    When a form goes into enter mode, the previous record is still displayed. This happens when hiding a combo box on a form using the 'OnEnterRecord' record event and <form>.new_record() form function. (This combo box is used for navigation on a form, so don't want it visible when in enter mode.) This problem does not show up using the navigation bar to enter a new record.

    To duplicate the problem, in the attached database, open the 'contacts' form and navigate to any existing record (either with the combo box or the navigation bar), and then click the 'new' button in the top right of the form. You will see the form go into enter mode, but still show the previous record. If you click the 'previous' button in the navigation bar, you will see the record number show the last record, indicating it went to a new record, but didn't show it. At this point if you use the 'next' button on the navigation bar, it works fine.

    Now, close the form and comment out the code in the table field rules 'OnEnterRecord' event, and try the same thing. Everything works fine (except, of course, the combo box isn't hidden). Is it a 'form' function conflicting with a 'table' event? Any comments?

    I submitted it as a bug report, but if anyone sees something I am doing wrong, please let me know.

    Thanks,
    Dan

  2. #2
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default Re: <form>.new_record() and hide combo. Is this a bug?

    I took a look. The sample you posted does not seem to work as you describe, or I'm missing something. When I click the NEW button the new record begins, but the combo box does not get hidden. I suggest you unzip the file you uploaded to a new machine or folder and run it from there to see what I mean. Thanks.


    Later on...

    I guess I don't know what you mean when you say...

    "... still show the previous record"

    The form goes into enter mode the fiield values of the previous record no longer appear. However, the most recent selection in the combobox continues to be displayed.

    -- tom
    Last edited by Tom Cone Jr; 11-06-2009 at 03:49 PM.

  3. #3
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default Re: <form>.new_record() and hide combo. Is this a bug?

    Dan, I could not find a way to hide the combo box and begin a new record. By the time the form processes the instruction to repaint the control the new record has already begun.

    I don't use field rules for this sort of thing, preferring not to bind field rule record events to specific form layouts...

    So, I've commented out the onEnterRecord event you wrote, and then modified the "New" button script as follows:

    Code:
    result = hidecombo(.t.)
    if result then 
    	parentform.resynch()
    	xbasic_wait_for_idle()
    	parentform.new_record()
    end if	
    
    Function hidecombo as L (hide_it as L)
    	if hide_it then
    	    'parentform:findcombo.hide()
    	    parentform:findcombo.disable()
    	    parentform:findcombo.refresh()
    	    hidecombo = .t.
    	else
    	    'parentform:findcombo.show()
    	    parentform:findcombo.enable()
    	   hidecombo = .f.
    	end if
    end function
    This will leave the combo showing, but disable it so the user can't do anything with it if they get bored entering the new record and start clicking just see what might happen.

    You'll need to enable the combo box again when the user saves or cancels the new record. HTH

    -- tom

  4. #4
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default Re: <form>.new_record() and hide combo. Is this a bug?

    Dan, this was bugging me, so to speak, so I took a second look. Your hoist by your own petard.

    Your form's OnFetch event is

    Code:
    topparent:findcombo.show()
    If you trace the events that fire when you push button1 ("New") you'll see that the form fires the onFetch event a couple of times after the button's onPush. Using my button script to hide the control (instead of your field rule) the effect is to hide the control, and then show it again.

    Later on...

    So, the answer to your orignal question is no. Not a bug.

    Here's a working example for you to play with. Again, pls note I am not using your field rule approach.

    HTH

    -- tom
    Last edited by Tom Cone Jr; 11-06-2009 at 05:14 PM.

  5. #5
    Member
    Real Name
    Dan Hooley
    Join Date
    Jan 2008
    Location
    Washington (State)
    Posts
    343

    Default Re: <form>.new_record() and hide combo. Is this a bug?

    OK, comment out the OnFetch event. It has nothing to do with it. It works exactly the same. I only put that there to bring the combobox back when you click the previous or next buttons. The problem is not with hiding and showing the combobox, or what is displayed in the combobox.

    If it is not a bug, why does it work just fine using the nav bar, but not using the button on the form?


    The sample you posted does not seem to work as you describe, or I'm missing something. When I click the NEW button the new record begins, but the combo box does not get hidden. I suggest you unzip the file you uploaded to a new machine or folder and run it from there to see what I mean. Thanks.
    I unzipped it into a new folder and it works just as I described.
    Open the form, and click on the 'new' button on the form, not on the nav bar. It changes to enter mode, (and the combo box disappears) but the field values still show the values from the previous record. Click the 'previous' button on the nav bar, and record 11 appears, indicating it was in a new record, but did not clear the fields. This does not happen if I do not try to hide the combo box (comment out the OnEnterRecord code), or if I use the nav bar to enter a new record. Just on the 'new' button on the form.

    I guess I don't know what you mean when you say...

    "... still show the previous record"
    What I mean is; the field values still display the values from the previous record. Whatever record you were in before clicking the 'new' button, still shows in the new record.

    The form goes into enter mode the fiield values of the previous record no longer appear. However, the most recent selection in the combobox continues to be displayed.
    The problem is this doesn't happen. The field values from the previous record DO still appear.

    As far as your modification, the way I am doing it is part of a bigger scheme of things, that works on multiple forms, so I cannot just modify the code on that button. I just pared it down to this example to show the problem.

    Dan

  6. #6
    Member
    Real Name
    Doug McLean
    Join Date
    Apr 2004
    Posts
    25

    Default Re: <form>.new_record() and hide combo. Is this a bug?

    Tom's solutions seems to work fine.

    Try this approach:
    comment out the onenterrecord event
    add topparent:Findcombo.HIDE() to the end of the script for the new button

  7. #7
    "Certified" Alphaholic Tim Kiebert's Avatar
    Real Name
    Tim Kiebert
    Join Date
    Jul 2004
    Location
    Geelong, Victoria, Australia
    Posts
    2,785

    Default Re: <form>.new_record() and hide combo. Is this a bug?

    Dan,

    I see the behavior exactly as you describe. Removing the code in the field rules eliminates the issue. I think there is a timing issue between the form and the field rule code. When a new record is started from the toolbar the form does not have focus so the new record command is given from a different context. However when using the form button the form has focus and the conflict happens. This is my best guess.

    I do my very best to not add code to field rules that interacts with the form. It may very well work in many situations but I don't think field rules were intended for the application layer (ie forms and user interfaces). I see them as analogous to triggers and stored procedures in the SQL type databases. That is to manipulate the data at the table level.

    So I would not really consider it a bug. Maybe a limitation. It is also one of those areas that could change down the track when Alpha code gets tightened up. Either allowing it to work or not allowing something that does work now.

    Probably not what you want to hear. Sorry.

    Another way to hide your combo box is to place it on a conditional object. That way you don't need to adjust your code at all. For the expression use:
    Code:
    topparent.mode_get() <> "View"
    Tim Kiebert
    Eagle Creek Citrus
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

  8. #8
    Member
    Real Name
    Dan Hooley
    Join Date
    Jan 2008
    Location
    Washington (State)
    Posts
    343

    Default Re: <form>.new_record() and hide combo. Is this a bug?

    Hi Tim,

    Thanks for the reply. I wonder too if it has something to do with timing. At least you were able to see what I am talking about.

    I had thought of the conditional idea, and will explore that route, or just disable the combo box. Disabling seems to work, which seems odd. I still think, bug or not, it should not act that way. But I might still have to rethink the way I am doing things and see if I can improve it so I don't have to use field rules. It was just working so beautifully until I ran into this problem. Thanks again for your time. Will see what I can figure out.
    Dan

  9. #9
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default Re: <form>.new_record() and hide combo. Is this a bug?

    The problem is this doesn't happen. The field values from the previous record DO still appear.
    The problem is this doesn't happen. The field values from the previous record DO still appear.
    Dan, I'm sorry to have annoyed you. What you report is NOT what I saw on my XP Pro SP3 machine. Won't bother you again. -- tom

  10. #10
    Member
    Real Name
    Dan Hooley
    Join Date
    Jan 2008
    Location
    Washington (State)
    Posts
    343

    Default Re: <form>.new_record() and hide combo. Is this a bug?

    was out for the weekend...

    no problem, tom. I guess we were just not on the same page.

    I am not arguing with the idea of not using field rules to control forms, but just for interest sake, if you try this simple test;

    In my attached database, in the OnEnterRecord table event, change frm:FindCombo.hide() to frm:FindCombo.disable(), then in the OnFetch event in the form change topparent:FindCombo.show() to topparent:FindCombo.enable() and the problem goes away. By the problem I am talking about the fields showing the values from the record you just came from instead of being cleared like it should for a new blank record.

    This seems (IMHO) at the very least like an inconsistency in the program. Why would disable/enable work, but not hide/show? This took me a long time to test and figure out, and I don't think it is anywhere in the documentation.

    Dan
    Last edited by danh; 11-09-2009 at 05:21 PM.

  11. #11
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default Re: <form>.new_record() and hide combo. Is this a bug?

    Dan,

    Using your original database example I get different behavior than you describe.

    1) the code in the OnEnterRecord event does not hide the combo box. [ this I thought was the original problem, for which I've previously offered an alternative approach ]

    2) the data entry fields in the form do NOT retain the previous record's field values when the NEW button is pushed. The form goes into ENTER mode normally, and the data entry fields are blanked out, ready to receive new input; and, the next autoincremented customer id appears in place. [ pdf image of what I'm saying is attached ]

    I do not know why the previous record's field values persist for you. I'm running XP Pro SP3 and build 2095 / 3264 of Alpha Five vers 9.

    -- tom

  12. #12
    "Certified" Alphaholic Tim Kiebert's Avatar
    Real Name
    Tim Kiebert
    Join Date
    Jul 2004
    Location
    Geelong, Victoria, Australia
    Posts
    2,785

    Default Re: <form>.new_record() and hide combo. Is this a bug?

    Tom,

    It must be an environment thing, ie our machines. As noted previously I see the same as behaviour as Dan. I am running the same build as you but on Vista.

    Edit: I told a lie.
    On XP Pro SP3 and build 2095 / 3264 I see the same as Dan
    On Vista Business SP1 and build 2095 / 3264 I see the same as Tom
    Last edited by Tim Kiebert; 11-09-2009 at 07:05 PM.
    Tim Kiebert
    Eagle Creek Citrus
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

  13. #13
    Member
    Real Name
    Dan Hooley
    Join Date
    Jan 2008
    Location
    Washington (State)
    Posts
    343

    Default Re: <form>.new_record() and hide combo. Is this a bug?

    I'm running:
    Alpha Five Version (Registered): 9
    Build: 2095
    Addins: 3264
    Operating System: Microsoft Windows XP Professional Service Pack 3

    I had stated earlier that the code in the OnFetch event had nothing to do with it, and for me it doesn't, but I'm wondering now if in Tom's case and Tim's Vista case maybe its bringing the combo box back. Still doesn't explain the field values not clearing, but might have something to do with the combo box not getting hidden.

    I'm a little unsure when exactly the OnFetch event is supposed to fire. It fires when you move from record to record, but on my computer it doesn't fire when you move to a new record. Is that the way it's supposed to act? I guess it is not actually "fetching" another record so maybe so. I've ran into this before where it doesn't seem to fire when entering a new record. But maybe it does sometimes. Any comments?

    Dan

  14. #14
    Member
    Real Name
    Doug McLean
    Join Date
    Apr 2004
    Posts
    25

    Default Re: <form>.new_record() and hide combo. Is this a bug?

    I'm running:
    Alpha Five Version (Registered): 9
    Build: 2095
    Addins: 3264
    Operating System: Microsoft Windows XP Professional Service Pack 2

    I get different results when I add debug to your new button.

    debug(1)
    topparent.new_record()
    Debug(0)

    Executed line by line the program appears to work correctly (as anticipated). Comment out the debug and the errors you report appear. Could this be a timing issue?

  15. #15
    "Certified" Alphaholic
    Real Name
    Tom Cone Jr
    Join Date
    Apr 2000
    Location
    Florida
    Posts
    23,310

    Default Re: <form>.new_record() and hide combo. Is this a bug?

    A further complexity. I'm running vers 9 with the new browse object. Wonder if that accounts for the different browse behavior I'm seeing here?

    -- tom

  16. #16
    "Certified" Alphaholic Tim Kiebert's Avatar
    Real Name
    Tim Kiebert
    Join Date
    Jul 2004
    Location
    Geelong, Victoria, Australia
    Posts
    2,785

    Default Re: <form>.new_record() and hide combo. Is this a bug?

    That was good timing. Just on a coffee break.

    Same here Tom, new browse on both environments I posted earlier.
    Tim Kiebert
    Eagle Creek Citrus
    A complex system that does not work is invariably found to have evolved from a simpler system that worked just fine.

Similar Threads

  1. show/hide search part bug?
    By Steve Wood in forum Application Server Version 9 - Web/Browser Applications
    Replies: 1
    Last Post: 10-14-2009, 03:27 AM
  2. Combo Box Unique Value Bug
    By MikeC in forum Alpha Five Version 8
    Replies: 2
    Last Post: 03-13-2008, 11:48 PM
  3. Possible Bug-Record List combo box
    By russ Boehle in forum Alpha Five Version 8
    Replies: 0
    Last Post: 06-09-2007, 06:52 PM
  4. new_record() from form button
    By Mike Walsh in forum Alpha Five Version 4
    Replies: 6
    Last Post: 07-17-2001, 11:21 AM

Bookmarks

Posting Permissions

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