Alpha Video Training
Page 2 of 2 FirstFirst 12
Results 31 to 35 of 35

Thread: Inserting data

  1. #31
    Member
    Real Name
    Leong Tuck Shing
    Join Date
    Jun 2006
    Posts
    49

    Default Re: Inserting data

    Quote Originally Posted by madtowng View Post
    This is quite different than what we had as you are now using tablemin() instead of tablemax() (is this a separate module?)
    Hi Gregg, is the same module, I used tablemin bcos I need to goto the first record of "GE", then I use fetch_prev to get the last record of "G". That was my intention.
    The problem is the fetch_prev did not fetch the correct record, giving me "1031" for every alphabet. I think my fetch_prev routine is wrong.

    Regards

  2. #32
    "Certified" Alphaholic
    Real Name
    Gregg Schmidt
    Join Date
    Mar 2001
    Location
    Milwaukee
    Posts
    1,388

    Default Re: Inserting data

    I gave it a rewrite to accomplish what I understand is your goal.
    The code is designed to be loop friendly.
    I tested using data you displayed in yesterday's post.

    2019-10-10_3-36-30.png2019-10-10_3-37-47.png
    Code:
    dim vFamid as c
    dim vBranch as c
    dim luFilter[0] as p
    dim returnto as c
    
    ' My changes begin here
    luFilter[].original = <<%txt%
    branchcode = "<vBranch>" .and. left(customerid,1) = "<vfamid>" .and. left(customerid,2) <> "GE" 
    %txt%
    luFilter[].original = <<%txt%
    branchcode = "<vBranch>" .and. left(customerid,2) = "GE"  
    %txt%
    
    debug(1)
    vFamid="GE"
    vBranch = "AMK"
    returnto = "label1:"
    goto reuse
    label1:
    vFIDLast = tablemax("biocustomer",luFilter[useFilter].altered ,"customerid") 
    vCFID = increment_value(vFIDlast)
    
    vFamid="G"
    vBranch = "AMK"
    returnto = "label2:"
    goto reuse
    label2:
    vFIDLast = tablemax("biocustomer",luFilter[useFilter].altered ,"customerid") 
    vCFID = increment_value(vFIDlast)
    end 
    
    reuse:
    select
    	case left(vFamID,2) = "GE"
    		luFilter[2].altered = strtran(luFilter[2].original,"<vBranch>",vBranch)
    		luFilter[2].altered = strtran(luFilter[2].altered,"<vfamid>",vFamid)
    		useFilter=2			 
    	case else
    		luFilter[1].altered = strtran(luFilter[1].original,"<vBranch>",vBranch)
    		luFilter[1].altered = strtran(luFilter[1].altered,"<vfamid>",vFamid)		
    		useFilter=1
    end select
    select 
    	case returnto="label1:"
    		goto label1
    	case returnto="label2:"
    		goto label2	
    end select		
    end

  3. #33
    Member
    Real Name
    Leong Tuck Shing
    Join Date
    Jun 2006
    Posts
    49

    Default Re: Inserting data

    Quote Originally Posted by madtowng View Post
    I gave it a rewrite to accomplish what I understand is your goal.
    The code is designed to be loop friendly.
    I tested using data you displayed in yesterday's post.
    Gregg, you are fantastic. Your code are work perfectly. I will need to slowly dissolve your code to understand how it really work. Thanks Gregg.

  4. #34
    "Certified" Alphaholic
    Real Name
    Gregg Schmidt
    Join Date
    Mar 2001
    Location
    Milwaukee
    Posts
    1,388

    Default Re: Inserting data

    Leong,

    Glad to hear this.
    Please feel free to ask about any of the code.
    Ideally, I would put the code under the reuse: label into a function and
    eliminate all the goto / labels.

  5. #35
    "Certified" Alphaholic
    Real Name
    Gregg Schmidt
    Join Date
    Mar 2001
    Location
    Milwaukee
    Posts
    1,388

    Default Re: Inserting data

    Leong,

    As you might guess, I don't like using goto if it can be avoided, so I reworked this
    into a function that will even create a new vFAMID if necessary.
    After the function is in place, the code becomes so much easier.

    Code:
    debug(1)
    branch = "AMK"
    lastName = "Chan"
    vcFID = createFamID(lastname,branch)
    
    lastName = "Guest"
    vcFID = createFamID(lastName,branch)
    
    branch = "SEA"
    lastName = "Guest"
    vcFID = createFamID(lastName,branch)

    Code:
    FUNCTION createFamID AS C (lastName AS C, vBranch AS C )
    dim luFilter[0] as p
    luFilter[].original = <<%txt%
    branchcode = "<vBranch>" .and. left(customerid,1) = "<vfamid>" .and.  left(customerid,2) <> "GE"  
    %txt%
    luFilter[].original = <<%txt%
    branchcode = "<vBranch>" .and.  left(customerid,2) = "GE"  
    %txt%
    
    select
    	case lastName="Guest"
    		vFamid="GE"
    		luFilter[2].altered = strtran(luFilter[2].original,"<vBranch>",vBranch)
    		luFilter[2].altered = strtran(luFilter[2].altered,"<vfamid>",vFamid)
    		useFilter=2			 
    	case else
    		vFamid = left(lastName,1)
    		luFilter[1].altered = strtran(luFilter[1].original,"<vBranch>",vBranch)
    		luFilter[1].altered = strtran(luFilter[1].altered,"<vfamid>",vFamid)		
    		useFilter=1
    end select
    '''debug(1)
    if tablemax("biocustomer",lufilter[useFilter].altered,"customerid")="" then
    	select
    		case lastName = "Guest"
    			vFIDLast = "GE0000"
    		case else
    			vFIDLast = upper(left(lastName,1))+"00000"	
    	end select
    else
    	vFIDLast = tablemax("biocustomer",luFilter[useFilter].altered ,"customerid") 	
    end if
    
    createFamID = increment_value(vFIDlast)
    	
    END FUNCTION

Similar Threads

  1. inserting data into multiple tables(data binding)
    By amitloh in forum Mobile & Browser Applications
    Replies: 5
    Last Post: 07-03-2017, 02:19 PM
  2. Inserting data into embedded browse
    By Jcian in forum Alpha Five Version 9 - Desktop Applications
    Replies: 7
    Last Post: 06-15-2009, 03:03 PM
  3. Replies: 2
    Last Post: 06-05-2006, 07:58 AM
  4. Inserting data from one form into multiple tables
    By Page Sands in forum Alpha Five Version 6
    Replies: 15
    Last Post: 12-22-2004, 10:59 AM
  5. Lookups-Inserting data onto a form
    By Manish Bhalla in forum Alpha Five Version 4
    Replies: 2
    Last Post: 10-14-2000, 06:33 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
  •