Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Append Most recent Date

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Append Most recent Date

    Hello world, I need help writing a filter for an append operation. I have a table that holds class schedules for students, this table has many entries for the same student. What I would like to do is append from this table to an empty table with the exact same structure, the most recent class date for each ssn in the table (assuring that only one record per ssn is appended) the two fields that I am using is for the filter is START_DATE and SSN.

    The past year I've been working strictly on the web side of alpha using a sql back end so im a bit of at a loss when trying to write this filter, I know how to write this in sql but I guess I've forgotten how to handle this in dbf for alpha. Can anyone give me hand, it would be very much appreciated.

    #2
    Re: Append Most recent Date

    What I find handy is to open a browse and write a query by expression to get what I want.

    I then save the query and use it (or the code from it) in the operation.
    Al Buchholz
    Bookwood Systems, LTD
    Weekly QReportBuilder Webinars Thursday 1 pm CST

    Occam's Razor - KISS
    Normalize till it hurts - De-normalize till it works.
    Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
    When we triage a problem it is much easier to read sample systems than to read a mind.
    "Make it as simple as possible, but not simpler."
    Albert Einstein

    http://www.iadn.com/images/media/iadn_member.png

    Comment


      #3
      Re: Append Most recent Date

      I made an attempt at it using the default browse for my table hoping that the Genie would help to create a filter but I'm still not sure how to write it.

      Comment


        #4
        Re: Append Most recent Date

        The following should work. I personally would make it into a function (UDF). This only works because you stated that the source and target table are identical - ie. same fields in the same order. An append would be faster but maybe that isn't as important.

        Code:
        'set the table names
        	dim vsource_tbl as C="schedules"
        	dim vtarget_tbl as C="target"
        	
        'acquire a list of students social security number
        	dim vLssn as C
        	vLssn=word_unique(table.external_record_content_get(vsource_tbl,"ssn"),crlf())
        
        'get the record count for the wait dialog
        	dim vnrecs as N
        	vnrecs=line_count(vLssn)
        
        'get pointer to tables and open the tables
        	dim ts as p
        	dim tt as p
        	
        	ts=table.open(vsource_tbl)
        	tt=table.open(vtarget_tbl)
        	
        	dim cycle as N=0
        	DIM GLOBAL pDlg1 as {waitdialog}
        	pDlg1.Set_Title("Please Wait")
        	pDlg1.Create(1,"Percent")
        	
        'loop through the ssn list, filter the source table to the ssn in date order, 
        'get the last date record and write that record to the target table
        	dim vdata as B				'record data variable
        	dim vssn_now as C			'loop iteration ssn value
        	
        	for each foo in vLssn
        		vssn_now=alltrim(foo)
        		
        		'wait dialog report
        		cycle=cycle+1
        		pDlg1.Set_Message(vssn_now)
        		pDlg1.Set_Bottom_Message(str(cycle)+"  of  "+str(vnrecs))
        		pDlg1.Set_Percent(Var->cycle,Var->vnrecs)		
        		
        		'filter the source table to the now ssn in start_date order and get the last date record into variable
        		xs=ts.order("start_date","ssn="+quote(vssn_now))
        		if xs.records_get()>0
        			ts.fetch_last()
        			vdata=ts.record_data_get()
        			
        			'write to the target table
        			tt.enter_begin()
        			    tt.record_data_set(vdata)
        			tt.enter_end(.t.)
        		end if
        		
        	'get next ssn
        	next
        	
        'close the tables and the wait dialog at the end of the loop
        	ts.close()
        	tt.close()
        	pDlg1.close()
        	
        'report complete
        	msgbox("The last dates for each student have been written to the "+vtarget_tbl+" table.")
        Mike W
        __________________________
        "I rebel in at least small things to express to the world that I have not completely surrendered"

        Comment


          #5
          Re: Append Most recent Date

          Or create a summary operation that groups on Ssn and max on start_date.
          Al Buchholz
          Bookwood Systems, LTD
          Weekly QReportBuilder Webinars Thursday 1 pm CST

          Occam's Razor - KISS
          Normalize till it hurts - De-normalize till it works.
          Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
          When we triage a problem it is much easier to read sample systems than to read a mind.
          "Make it as simple as possible, but not simpler."
          Albert Einstein

          http://www.iadn.com/images/media/iadn_member.png

          Comment


            #6
            Re: Append Most recent Date

            Thanks for the reply, this code looks loaded but thank you for adding the comments, its very easy to read.

            Comment


              #7
              Re: Append Most recent Date

              Originally posted by Al Buchholz View Post
              Or create a summary operation that groups on Ssn and max on start_date.
              This was much easier to accomplish, thank you for the push in the right direction. It worked perfectly.

              Comment


                #8
                Re: Append Most recent Date

                Now create a set with the summary table as the parent that links to the original table with the ssn and max date.

                Then you have all the records to append (or copy) to the new table.
                Al Buchholz
                Bookwood Systems, LTD
                Weekly QReportBuilder Webinars Thursday 1 pm CST

                Occam's Razor - KISS
                Normalize till it hurts - De-normalize till it works.
                Advice offered and questions asked in the spirit of learning how to fish is better than someone giving you a fish.
                When we triage a problem it is much easier to read sample systems than to read a mind.
                "Make it as simple as possible, but not simpler."
                Albert Einstein

                http://www.iadn.com/images/media/iadn_member.png

                Comment

                Working...
                X