Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: Autoreturn -- again...

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1

    Default Autoreturn -- again...

    I asked this question before, and received several responses telling me it's a bad idea... However, nobody actually answered my question.

    In my application, it makes sense to autoreturn after three characters, or four characters...

    Here's the sequence of events:

    1) Customer calls our store and wants to schedule a free fence estimate.
    2) Employee opens my software and opens the "Customer" view.
    3) Employee asks for customer's telephone number.
    3a) Employee enters area code in the "area code" form -- and must hit the "TAB" key to move to the next form...
    3b) Employee enters prefix in the "prefix" form -- and must hit the "TAB" key to move to the next form...
    3c) Employee enters suffix in the "suffix" form -- and must hit the "TAB" key to move to the next form... At this point, the software executes an autofind with the following code in the Data Dictionary:

    Code:
            Set Field_Option Field Customer.Suffix       DD_AutoFind to True
    


    Everything works exactly as it should, but I would very much prefer NOT to force the employee to hit the TAB key three times...

    Ideally, the "area code" form would autoreturn after three (3) characters.

    Ideally, the "prefix" form would autoreturn after three (3) characters.

    Ideally, the "suffix" form would autoreturn after four (4) characters.

    Can you guys please help me make my employee's life easier by adding an autoreturn to these forms?

    thank you!



  2. #2
    Join Date
    Feb 2009
    Location
    Somewhere in Vermont, USA - unless I'm not
    Posts
    9,656

    Default Re: Autoreturn -- again...

    Untested (typed here) - but this might work:

    Code:
    Procedure OnChange
        Integer iLength
        String sValue
    
        Forward send OnChange
    
        Get Value to sValue
        If (Length(sValue) >= 3) Send Next    //change the # for each different form
    End_Procedure
    Garret

    All my life,I always wanted to be somebody. Now I see that I should have been more specific.


  3. #3

    Default Re: Autoreturn -- again...

    Thanks Garret -- that ALMOST works! The strange part is that the focus jumps over the next form, and goes to the following one.

    So, if we have three forms called AREACODE PREFIX and SUFFIX, and the user types "123" into the AREACODE form, the focus suddenly jumps to the SUFFIX form!

    Any idea why?

    Quote Originally Posted by Garret Mott View Post
    Untested (typed here) - but this might work:

    Code:
    Procedure OnChange
        Integer iLength
        String sValue
    
        Forward send OnChange
    
        Get Value to sValue
        If (Length(sValue) >= 3) Send Next    //change the # for each different form
    End_Procedure

  4. #4
    Join Date
    Feb 2009
    Location
    Queens, NY, NY
    Posts
    6,590

    Default Re: Autoreturn -- again...

    I suspect "Next" triggers onChange.

    Maybe try this:
    Code:
     
    Get Value to sValue
    Move (trim(sValue)) to sValue 
        If (Length(sValue) >= 3) Send Next    //change the # for each different form
    Else maybe you're gonna have to do sketchy stuff creating and setting "bNoJump" boolean variables...
    Michael Mullan.
    Danes Bridge Enterprises.

    ++++++++++++++++++++++++++++
    There is just today. Tomorrow is a concept
    that is mostly theoretical. -- GM Wylie
    ++++++++++++++++++++++++++++

  5. #5

    Default Re: Autoreturn -- again...

    Hmmmm -- that didn't change anything... I took out the Forward Send statements -- that didn't change anything. I took out the procedures from the second and third forms, and that didn't change anything! This is bizarre!

    BUT, if I leave the code the way it was, the SUFFIX form actually works correctly! "Send Next" sends the focus to the very next form! My mind is boggled!

    Is there a way to force the focus / cursor to go to a specific field? Instead of saying "Send Next", maybe I can tell the focus exactly where to go?

    thank you!


    Quote Originally Posted by Michael Mullan View Post
    I suspect "Next" triggers onChange.

    Maybe try this:
    Code:
     
    Get Value to sValue
    Move (trim(sValue)) to sValue 
        If (Length(sValue) >= 3) Send Next    //change the # for each different form
    Else maybe you're gonna have to do sketchy stuff creating and setting "bNoJump" boolean variables...

  6. #6
    Join Date
    Feb 2009
    Posts
    4,839

    Default Re: Autoreturn -- again...

    Is the order of the forms in the source code the same as the display on the screen as this dictates the tab order and not the relative position of the Location property of each form
    Success consists of going from failure to failure without loss of enthusiasm - Winston Churchill

  7. #7

    Default Re: Autoreturn -- again...

    Yes. The order in the code is the same as the order on the screen. If I start at AREACODE and hit the "TAB" key, the focus goes to PREFIX. Hitting the "TAB" key again, the focus goes to SUFFIX.

    Hitting the "TAB" key does exactly what it should -- and that is how we are entering the phone number now. The problem is that "SEND NEXT" on AREACODE makes the focus jump directly to SUFFIX. (PREFIX is skipped.)

    Quote Originally Posted by Focus View Post
    Is the order of the forms in the source code the same as the display on the screen as this dictates the tab order and not the relative position of the Location property of each form

  8. #8
    Join Date
    Feb 2009
    Location
    Hengelo, Netherlands
    Posts
    9,139

    Default Re: Autoreturn -- again...

    Guy,

    Following test code works:
    Code:
    Use Windows.pkg
    Use cHtmlHelp.pkg
    Use cApplication.pkg
    Use cConnection.pkg
    
    Object oHtmlHelp is a cHtmlHelp
    End_Object
    
    Object oApplication is a cApplication
        Object oConnection is a cConnection
            Use LoginEncryption.pkg
            Use DatabaseLoginDialog.dg
        End_Object
    End_Object
    
    Class cAutoReturnForm is a Form
        Procedure Construct_Object
            Forward Send Construct_Object
    
            Property Integer piMaxChars 3
        End_Procedure
    
        Procedure OnChange
            Handle hoFocus
            String sValue
            Integer iMaxChars
    
            Get Focus to hoFocus
            If (hoFocus = Self) Begin
                Get Value to sValue
                Get piMaxChars to iMaxChars
                If (Length (sValue) >= iMaxChars) Begin
                    Send Next
                End
            End
        End_Procedure
    End_Class
    
    Object oPanel is a BasicPanel
        Set Size to 186 367
    
        Object oFirstForm is a cAutoReturnForm
            Set Size to 12 30
            Set Location to 5 10
        End_Object
    
        Object oSecondForm is a cAutoReturnForm
            Set Size to 12 30
            Set Location to 5 45
        End_Object
    
        Object oThirdForm is a cAutoReturnForm
            Set Size to 12 30
            Set Location to 5 80
        End_Object
    
        Object oDummyForm is a Form
            Set Size to 12 100
            Set Location to 25 11
        End_Object
    End_Object
    
    Start_UI oPanel
    Regards,
    Data Access Worldwide
    Vincent Oorsprong

  9. #9

    Default Re: Autoreturn -- again...

    Thanks Vincent -- that certainly gets me a lot closer, but now I have other problems.

    1) I get three Unhandled Exception errors now. Not sure why, but I suspect it has to do with the three "cAutoReturnForm" declarations.
    2) The autoreturn part works, but now it does not perform the DD_Autofind (which used to work).
    3) The "Clear All" button does not clear those three entry items any more (which used to work).

    My code is below:



    Code:
    // C:\DataFlex Projects\SSS Fence\AppSrc\Customer.vw
    // Customer
    //
    Use DFClient.pkg
    Use DFEntry.pkg
    Use Windows.pkg
    Use cHtmlHelp.pkg
    Use cApplication.pkg
    Use cConnection.pkg
    
    Use cCustomerDataDictionary.dd
    Use cCustomerToScheduleDataDictionary.dd
    Use cHistoryDataDictionary.dd
    Use Windows.pkg
    Object oHtmlHelp is a cHtmlHelp
    End_Object
    
    Object oApplication is a cApplication
        Object oConnection is a cConnection
            Use LoginEncryption.pkg
            Use DatabaseLoginDialog.dg
        End_Object
    End_Object
    
    Class cAutoReturnForm3 is a Form
    
        Procedure Construct_Object
            Forward Send Construct_Object
            Property Integer piMaxChars 3
        End_Procedure
    
        Procedure OnChange
            Handle hoFocus
            String sValue
            Integer iMaxChars
            Get Focus to hoFocus
            If (hoFocus = Self) Begin
                Get Value to sValue
                Get piMaxChars to iMaxChars
                If (Length (sValue) >= iMaxChars) Begin
                    Send Next
                End
            End
        End_Procedure
    
    End_Class
    
    Class cAutoReturnForm4 is a Form
    
        Procedure Construct_Object
            Forward Send Construct_Object
            Property Integer piMaxChars 4
        End_Procedure
    
        Procedure OnChange
            Handle hoFocus
            String sValue
            Integer iMaxChars
            Get Focus to hoFocus
            If (hoFocus = Self) Begin
                Get Value to sValue
                Get piMaxChars to iMaxChars
                If (Length (sValue) >= iMaxChars) Begin
                    Send Next
                End
            End
        End_Procedure
    
    End_Class
    
    Activate_View Activate_oCustomer for oCustomer
    
    Object oCustomer is a dbView
        Set Location to 5 4
        Set Size to 144 305
        Set Label To "Customer"
        Set Border_Style to Border_Thick
        Set Auto_Clear_DEO_State to False
        
        Object oCustomerToSchedule_DD is a cCustomerToScheduleDataDictionary
        End_Object 
    
        Object oCustomer_DD is a cCustomerDataDictionary
            
            
            Set Field_Option Field Customer.Suffix              DD_AutoFind to True
            
            Set Field_Option Field Customer.Area_Code      DD_Required to True
            Set Field_Option Field Customer.Prefix             DD_Required to True
            Set Field_Option Field Customer.Suffix             DD_Required to True
            Set Field_Option Field Customer.Address          DD_Required to True
            Set Field_Option Field Customer.City                DD_Required to True
            Set Field_Option Field Customer.State              DD_Required to True
            Set Field_Option Field Customer.Zip                 DD_Required to True
            Set Field_Option Field Customer.Side_Of_Town DD_Required to True
            
            Set Field_Option Field Customer.State              DD_CapsLock to True
            Set Field_Option Field Customer.Side_Of_Town DD_CapsLock to True
            
        End_Object 
    
        Set Main_DD To oCustomer_DD
        Set Server  To oCustomer_DD
    
        Object oCustomerArea_Code is a cAutoReturnForm3
            Entry_Item Customer.Area_Code
            Set Size to 12 34
            Set Location to 5 54
            Set peAnchors to anTopLeftRight
            Set Label to "Main Phone"
            Set Label_Justification_Mode to JMode_Right
            Set Label_Col_Offset to 0
            Set Label_row_Offset to 0
        End_Object 
    
        Object oCustomerPrefix is a cAutoReturnForm3
            Entry_Item Customer.Prefix
            Set Size to 12 34
            Set Location to 5 97
            Set peAnchors to anTopLeftRight
            Set Label_Justification_Mode to JMode_Right
            Set Label_Col_Offset to 0
            Set Label_row_Offset to 0
        End_Object 
    
        Object oCustomerSuffix is a cAutoReturnForm4
            Entry_Item Customer.Suffix
            Set Size to 12 34
            Set Location to 5 140
            Set peAnchors to anTopLeftRight
            Set Label_Justification_Mode to JMode_Right
            Set Label_Col_Offset to 0
            Set Label_row_Offset to 0
        End_Object 
    
        Object oCustomerFirst_Name is a dbForm
            Entry_Item Customer.First_Name
            Set Size to 12 126
            Set Location to 20 54
            Set peAnchors to anTopLeftRight
            Set Label to "First Name"
            Set Label_Justification_Mode to JMode_Right
            Set Label_Col_Offset to 0
            Set Label_row_Offset to 0
        End_Object 
    .
    .
    .
    



    Click image for larger version. 

Name:	Unhandled.jpg 
Views:	16 
Size:	235.5 KB 
ID:	13519
    Last edited by the Guy; 5-Mar-2020 at 12:03 PM.

  10. #10
    Join Date
    Feb 2009
    Location
    Hengelo, Netherlands
    Posts
    9,139

    Default Re: Autoreturn -- again...

    Guy,

    My example wasn't data-aware and I remember you talked about autofind so this needs to be used, so change
    Code:
    Class cAutoReturnForm is a Form
    into
    Code:
    Class cAutoReturnForm is a dbForm
    PS: Instead defining two classes for autoreturn, one with piMaxChars is 3 and one with piMaxChars is 4 you simply set the piMaxChars property in the object. In fact by making it a dbForm we can get rid of the property and use the length defined for the column in the table.
    Regards,
    Data Access Worldwide
    Vincent Oorsprong

Posting Permissions

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