0

How to use the "View" element

Hello, when we create a database, we can add an element called "View".

Can you please tell me how to concrete use this field?

Because I always get the error message "Expression does not returns records" when I want to define the columns.

Thanks in advance for your help.

Have a nice day,

David W.

15 replies

null
    • Nick
    • 5 yrs ago
    • Reported - view

    Hi David,

    let's say you have a table Invoices and you you want a View for today Invoices.

    Now use this code:

     

    let t := t(today());
    select Invoices where InvoiceDate = t

     

    In the field edit screen you can Edit (select) Columns.

    • Nick
    • 5 yrs ago
    • Reported - view

    Sorry...

    should be:

    let t := today();

    select Invoices where InvoiceDate = t

    • David_WILLOX
    • 5 yrs ago
    • Reported - view

    Thanks for your feedback, Nick.

    • Admin.11
    • 2 yrs ago
    • Reported - view

    Just came across this post.

     

    I am trying to use the "view" Function to view certain guests of a table for that particular day for a particular event.

    My current code is:

    let t := today();
    select 'Snorkel/Sea Scooter Guests' where Tour = 1 and t

    This is showing guests, but its basically listing every guest on my table that is on tour 1, regardless of the date they are booked on.

     

    any suggestions?

    the table where the information is is called 'Snorkel/Sea Scooter Guests'

      • Fred
      • 2 yrs ago
      • Reported - view

      Admin The "and t" doesn't make sense to Ninox. You need to provide a field for it to check agains.

      Try:

      let t := today();
      select 'Snorkel/Sea Scooter Guests' where Tour = 1 and DateFieldName = t
      

      or you can remove one line of code and just put:

      select 'Snorkel/Sea Scooter Guests' where Tour = 1 and DateFieldName = today()
      
      • Admin.11
      • 2 yrs ago
      • Reported - view

      Fred Thanks for the suggestions.

      I have tried both lines and no data is showing.

      here's a screenshot of the table name and field that I can't seem to get Ninox to recognise.

      here is the table that i am trying to pull information from.

      this is the code that i currently have

      select 'Snorkel/Sea Scooter Guests' where Tour = 1 and 'Date of Tour' = today()

      the table is called 'Snorkel/Sea Scooter Guests'

      and the 2 fields that are unique is the Tour must = 1 and the date must be the day the form is in.

      • Admin.11
      • 2 yrs ago
      • Reported - view

      @Fred i tried

      select 'Snorkel/Sea Scooter Guests' where 'Date of Tour' = today()

      just to try and get the table to show something unique to that day and still showing nothing, which tells me that Ninox does not seem to recognise "date of Tour' and today.

      • Fred
      • 2 yrs ago
      • Reported - view

      Admin The table of Guests, is that view element or the actual table name?

      • Admin.11
      • 2 yrs ago
      • Reported - view

      Fred that's actual table name

      • Admin.11
      • 2 yrs ago
      • Reported - view

      Admin the name on the tables is just the name ive given it for the field, the actaul table is linked to the form that i am working on

      • Admin.11
      • 2 yrs ago
      • Reported - view

      Fred  the name on the tables is just the name ive given it for the field, the actaul table is linked to the form that i am working on

      • Fred
      • 2 yrs ago
      • Reported - view

      I tried something similar:

      (select Table2)[Date = today()]
      

      and it works in a view element for me, so the structure works.

      It is good that you simplified the code to check the logic. Now can you check that you have records in 'Snorkel/Sea Scooter Guests' where 'Date of Tour' equals today. If you want you can hard code the date you show me "13/05/2022" in place of today() and see if that returns the record.

      Then my next question is the field Tour in the 'Snorkel/Sea Scooter Guests' table. My wee brain is having a hard figuring out your tables and fields and relationships.

      • Admin.11
      • 2 yrs ago
      • Reported - view

      Fred thanks for your assistance, Ill break down my table relationships

      I have a table/form called Snorkel / Sea Scooter Bookings. This is the "main" form where the details for each tour is completed.

      I have been using the "tab" feature to break up the table making it look more user friendly.

      I then have another table called Snorkel/Sea Scooter Guests which is linked to the first table with a

      "Reference from Snorkel/Sea Scooter Bookings to Snorkel/Sea Scooter Guests" This table is also Compositioned to the main table (Snorkel/Sea Scooter Bookings)

      The idea is that each "tab" on the main table shows information for particular tour. the last "tab" is where the staff can add a record to the Guest table that is linked.

      The view function was to then show just the guests that are booked on a particular tour in the relevent tabs

      as shown here:

      • Admin.11
      • 2 yrs ago
      • Reported - view

      Fred I inputted that code 

      (select 'Snorkel/Sea Scooter Guests')['Date of Tour' = today()]

      and it does show me the guests. but as before, it is showing me all the guests that are on the table, regardless of the date. as shown below

      Please note that the guests in this picture are fictional

      • Admin.11
      • 2 yrs ago
      • Reported - view

      Fred Thankyou very much for your help. I Flukely worked it out.

      I assigned 'Date of Booking' to the Date field in the Main table and then told the 'view function' to lookup guests in a certain group and with their "Date of Tour" to match the date in the main table.

      Sounds to simple once you broke it down.

      let 'Date of Booking' := Date;
      (select 'Snorkel/Sea Scooter Guests')[Tour = 1 and 'Date of Tour' = 'Date of Booking']

       

      Still got more tests to do to make sure this is the fix but fingers cross this works

Content aside

  • 2 yrs agoLast active
  • 15Replies
  • 1997Views
  • 2 Following