4 Replies Latest reply on Dec 5, 2010 9:17 PM by xtremu

    Problem in TimeStart and TimeEnd

    xtremu

      Title

      Problem in TimeStart and TimeEnd

      Post

      I have two tables, Student Table and AccessLog table

      Student Table

      AccessLog table

      Student Number

      Number

      StudentID

      Number

      LastName

      Text

      TimeStart

      Time

      FirstName

      Text

      TimeEnd

      Time

      StudentID

      Number (AutoSerial)

       

       

      Barcode

      Number

       

       

      Relationship is Student:StudentID and AcccessLog:StudentID.

      I made a portal in the Student Table for TimeStart and TimeEnd fields. I want to view the Time of the system in TimeStart fields for his/her first entry using his/her student number and the second entry will log the time in TimeEnd field of the portal etc.loop it up to the last entry. I have TimeIn log for now and my problem is the TimeEnd log doesn’t show in the TimeEnd field. Anybody help. I’m using FileMaker Pro 11 Advanced. I am developing a simple Time Entry Monitoring of the students. Below is the script:

      Thanks in advanced and more power FM.

      xtremu

      access_log_script.jpg

        • 1. Re: Problem in TimeStart and TimeEnd
          RonCates

          Well, I must say, I have reread this post several times and still find it as confusing as the first.

          Let's break it down.

          "I want to view the Time of the system in TimeStart fields for his/her first entry"
          First entry into what? The file? A certain table? A certain record?

          "the second entry will log the time in TimeEnd field of the portal etc"
          So you want to log the time of first entry and the time of second entry? Again, entry into what?

          "I have TimeIn log for now and my problem is the TimeEnd log doesn’t show in the TimeEnd field"
          What do you mean by TimeIn log and TimeOut log?

          "loop it up to the last entry"
          No idea what this means.

          * My point here is that you will get much better results from these forums if you reread your own post carefully. Do not assume that we know anything about the system you are working on because we don't.  

          Now your script. Here is the logic.

          Do a find for an empty TimeStart field in your AccessLog table.

          If there is only 1 record found with an empty TimeStart field, enter the current time in the TimeStart field of that record.

          If there is more than one record found with an empty TimeStart field, sort the records, go to the next record and enter the current time in the TimeStart field of that record.

          If there are no records with an empty TimeEnd field found, or more than 1 field with an empty TimeStart field, Do a find for the current time in the TimeEnd field.

          If the current time is found in the TimeEnd field of more than 0 records, create a new record and enter the current time in the TimeEnd field.

          Otherwise show a message. "No records found".

           *When scripting, try translating your script into simple layman's terms. I often use a piece of paper to jot it down and read through the logic. This will often reveal any holes in the logic of what you are doing. If it doesn't make sense when you write it out. It probably doesn't make sense to FileMaker either.

          So, really, the only thing I was able to get from your post is that you want an Access Log system. So here is how I track users from the time they log into my system to the time they log out or close down.

          First, in your AccessLog table you will need to ad an auto enter serial number ID field.

          I use a script set to run when the file is opened.

          The user logs in with their user name and password. My script captures the user name, goes to my Employee table, does a find for the user name. When found, set a variable with the Employee ID from the found record. Then goto my Access Log table, create a new record. Enter the Employee ID  and enter the current time in the TimeStart field. Then set a global variable with the record ID of the Access Log record just created. The user goes on to do thier thing.

          At the end of the user's session I use a script set to run when the file is closed.

          When the user logs out or closes the file the script goes to my Access Log table, does a find using the AccessLog record ID I captured when the user logged in. When it finds the record created at the beginning of the session enter the current time in the TimeEnd field.

          Done.

          This technique assumes that you are looking to create an access log to track when users log in and out of the system. My Employee table would be the equivalen of your student table.

          • 2. Re: Problem in TimeStart and TimeEnd
            xtremu

            Thanks Ron for the detailed and quick reply. Your intuition is right about what I wish. Here is my reply for clarifications.

            "I want to view the Time of the system in TimeStart Fields in my portal for his/her first entry" - First entry of that certain record or that student into the StudentNumber field.

            "the second entry will log/record the system time in TimeEnd Field of the portal etc" So you want to log the time of first entry and the time of second entry? - Yes log/record that time in the TimeStart and TimeEnd Fields in the portal of that certain record.

            "loop it up to the last entry" No idea what this means.- I mean loop that activity like: first entry, record that time in TimeStart Field in the portal, second entry record that time in TimeEnd Field in the portal, third entry, record another time in the TimeStart Field in the portal, fourth entry, record another time in the TimeEnd Field in the portal, loop up to the last entry of that student or that certain record.

            Thanks and hope you can help me out on this.

             xtremu

            • 3. Re: Problem in TimeStart and TimeEnd
              RonCates

              I think I am still going to need a little clearification. Mostly because it would help to understand what you are trying to accomplish and to some degree why. The bigger picture is what I am looking for. Understanding what you would like to have when you are done is very helpful.

              So as I understand it, your user will go to a record in a layout that has a portal with a timelog for activity on the spacific record?
              - It would help to know what kind of data they are entering and into what table for what purpose.

              When the user makes thier first entry into a field on the layout a script will record the time in the portal as "Time Start"?
              When they make a second entry, the time will be recorded as "Time End" and so on?
              - Are you trying to record how long it takes for your users to accomplish the first and second entry?
              - Why? In other words, when you go back to look at this record, what do you want it to tell you?

              So, going by what I understand so far, here is where I would start.

              Using a script fired by a script trigger on each of the fields in question. 

              Set Variable [$$RecordID; YourTable::ID]
              Go To a Layout [a layout based on your log table]
              If [ IsEmpty ($$LogID ) ]
              New Record/Request
              Set Variable [$$LogID; Accesslog::ID]
              Set Field [Accesslog::RecordID; $$RecordID]
              Set Field [Accesslog::TimeStart ; Get ( CurrentTime )]
              Go To Layout [ original layout ]
              Else
              Enter Find Mode
              Set Field [ Accesslog::ID ; $$LogID ]
              Perform Find
              Set Field [ Accesslog::TimeEnd ; Get ( CurrentTime )]
              Set Variable [$$LogID; ""]
              Go To Layout [ original layout ]
              End If

              The break down;

              User enters data in the first field firing the script.

              Capture the id of the current record in $$RecordID

              Go to a layout based on the Access Log table

              Check to see if our global variable $$LogID has a value

              If not we create a new record, enter the time in the Time Start field and the RecordID in the foriegn key field.

              Capture the record id of the new record we just created in $$LogID

              Go back to the original layout

               

              If our $$LogID Variable has a value, then we do a find for that record id in $$LogID.

              When we have found the record, enter the current time in the TimeEnd field, clear the $$LogID variable

              Go back to the original layout

               

              Hopefully this will give you a starting point. Others may have different approaches to suggest.

              • 4. Re: Problem in TimeStart and TimeEnd
                xtremu

                Ron,

                - It would help to know what kind of data they are entering and into what table for what purpose. = StudentNumber data, Student Table, what field? = StudentNumber field, what purpose? = system will find this record or information.

                - When the user makes thier first entry into a field on the layout a script will record the time in the portal as "Time Start"? = YES, that is StudentNumber field in the Student Table.

                When they make a second entry, the time will be recorded as "Time End" and so on? = YES Ron

                - Are you trying to record how long it takes for your users to accomplish the first and second entry? No time limit Ron, as long as they enter their student number that's it, script will record the time either in TimeStart or TimeEnd in the portal.

                - Why? In other words, when you go back to look at this record, what do you want it to tell you? Just to monitor all entries of this student or this specific record Ron.

                Anyway here's my table and fields Ron,

                Student Table                                                                 AccessLog table

                • Student Number - Number                                   TimeStart      - Time
                • LastName           - Text                                         TimeEnd       - Time
                • FirstName           - Text                                      
                • StudentID          - Number (AutoSerial)                 StudentID    Number

                Relationship is Student Table:StudentID and AccessLog:StudentID

                Objective: 1. To monitor and record the time of the student of each entry they have  in the TimeStart and TimeEnd field in the portal shown in the Student Table Layout.

                Note: - Every student has their own record such as Name, LastName, FirstName, StudentNumber, picture etc..

                         - TimeStart and TimeEnd are fields in portal from AccessLog table shown in the Student Table.

                         - Every student has their own ID with barcode: (barcode=student number)

                Activity: If the student scan their ID or input their student number in the StudentNumber field, consider this as their first entry, then script will record the computer system time in TimeStart Field in the portal, second entry record that time in TimeEnd Field in the portal, third entry, record another time of that student or that record in the TimeStart Field in the portal, fourth entry, record another time of that student or that record in the TimeEnd Field in the portal etc.., loop this up to the last entry of that student or that certain record. That’s it Ron.

                 Thanks in advance for your effort Ron.

                xtremu